/** * Check if an operand is registered for the given token. * * @param Token $token The token to check for. * @return boolean True if a operand for the given token exists, false otherwise. */ public function isRegistered(Token $token) { if (isset($this->operands[$token->getCode()])) { return true; } return false; }
/** * Test all getters for the values set with the constructor. */ public function testConstructorAccessors() { $code = mt_rand(1, 30); $value = sha1(microtime(true)); $offset = mt_rand(1, 100); $token = new Token($code, $value, $offset); $this->assertSame($code, $token->getCode()); $this->assertSame($value, $token->getValue()); $this->assertSame($offset, $token->getOffset()); }
/** * Gets an ternary operator from table. * * @param Token $token The token for which the operator should be returned. * @return operators\TernaryOperator The operator object for the given token. * @throws UnsupportedOperatorException if the operator doesn't exists in table. */ public function getTernaryOperator(Token $token) { if (isset($this->ternary['if'][$token->getCode()])) { return $this->ternary['if'][$token->getCode()]; } else { if (isset($this->ternary['else'][$token->getCode()])) { return $this->ternary['else'][$token->getCode()]; } } throw new UnsupportedOperatorException("No ternary operator with code `{$token->getCode()}` exists in table"); }