public function testIsBool() { $this->assertTrue(Context::isBool('true')); $this->assertTrue(Context::isBool('false')); $this->assertFalse(Context::isBool('tru')); $this->assertFalse(Context::isBool('falsee')); }
/** * Parses a boolean. * * @return Token */ public function parseBool() { if ($this->last + 3 >= $this->len) { // At least `min(strlen('TRUE'), strlen('FALSE'))` characters are // required. return null; } $iBak = $this->last; $token = $this->str[$this->last] . $this->str[++$this->last] . $this->str[++$this->last] . $this->str[++$this->last]; // _TRUE_ or _FALS_e if (Context::isBool($token)) { return new Token($token, Token::TYPE_BOOL); } elseif (++$this->last < $this->len) { $token .= $this->str[$this->last]; // fals_E_ if (Context::isBool($token)) { return new Token($token, Token::TYPE_BOOL, 1); } } $this->last = $iBak; return null; }