Pull merge.
[yaffs-website] / vendor / phpspec / prophecy / src / Prophecy / Argument / Token / LogicalNotToken.php
1 <?php
2
3 /*
4  * This file is part of the Prophecy.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *     Marcello Duarte <marcello.duarte@gmail.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Prophecy\Argument\Token;
13
14 /**
15  * Logical NOT token.
16  *
17  * @author Boris Mikhaylov <kaguxmail@gmail.com>
18  */
19 class LogicalNotToken implements TokenInterface
20 {
21     /** @var \Prophecy\Argument\Token\TokenInterface  */
22     private $token;
23
24     /**
25      * @param mixed $value exact value or token
26      */
27     public function __construct($value)
28     {
29         $this->token = $value instanceof TokenInterface? $value : new ExactValueToken($value);
30     }
31
32     /**
33      * Scores 4 when preset token does not match the argument.
34      *
35      * @param $argument
36      *
37      * @return bool|int
38      */
39     public function scoreArgument($argument)
40     {
41         return false === $this->token->scoreArgument($argument) ? 4 : false;
42     }
43
44     /**
45      * Returns true if preset token is last.
46      *
47      * @return bool|int
48      */
49     public function isLast()
50     {
51         return $this->token->isLast();
52     }
53
54     /**
55      * Returns originating token.
56      *
57      * @return TokenInterface
58      */
59     public function getOriginatingToken()
60     {
61         return $this->token;
62     }
63
64     /**
65      * Returns string representation for token.
66      *
67      * @return string
68      */
69     public function __toString()
70     {
71         return sprintf('not(%s)', $this->token);
72     }
73 }