Chris@0: Chris@0: * Marcello Duarte Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Prophecy\Argument\Token; Chris@0: Chris@0: /** Chris@0: * Logical NOT token. Chris@0: * Chris@0: * @author Boris Mikhaylov Chris@0: */ Chris@0: class LogicalNotToken implements TokenInterface Chris@0: { Chris@0: /** @var \Prophecy\Argument\Token\TokenInterface */ Chris@0: private $token; Chris@0: Chris@0: /** Chris@0: * @param mixed $value exact value or token Chris@0: */ Chris@0: public function __construct($value) Chris@0: { Chris@0: $this->token = $value instanceof TokenInterface? $value : new ExactValueToken($value); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Scores 4 when preset token does not match the argument. Chris@0: * Chris@0: * @param $argument Chris@0: * Chris@0: * @return bool|int Chris@0: */ Chris@0: public function scoreArgument($argument) Chris@0: { Chris@0: return false === $this->token->scoreArgument($argument) ? 4 : false; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns true if preset token is last. Chris@0: * Chris@0: * @return bool|int Chris@0: */ Chris@0: public function isLast() Chris@0: { Chris@0: return $this->token->isLast(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns originating token. Chris@0: * Chris@0: * @return TokenInterface Chris@0: */ Chris@0: public function getOriginatingToken() Chris@0: { Chris@0: return $this->token; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns string representation for token. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function __toString() Chris@0: { Chris@0: return sprintf('not(%s)', $this->token); Chris@0: } Chris@0: }