1 | <?php |
||
21 | class ArrayEntryToken implements TokenInterface |
||
22 | { |
||
23 | /** @var \Prophecy\Argument\Token\TokenInterface */ |
||
24 | private $key; |
||
25 | /** @var \Prophecy\Argument\Token\TokenInterface */ |
||
26 | private $value; |
||
27 | |||
28 | /** |
||
29 | * @param mixed $key exact value or token |
||
30 | * @param mixed $value exact value or token |
||
31 | */ |
||
32 | public function __construct($key, $value) |
||
37 | |||
38 | /** |
||
39 | * Scores half of combined scores from key and value tokens for same entry. Capped at 8. |
||
40 | * If argument implements \ArrayAccess without \Traversable, then key token is restricted to ExactValueToken. |
||
41 | * |
||
42 | * @param array|\ArrayAccess|\Traversable $argument |
||
43 | * |
||
44 | * @throws \Prophecy\Exception\InvalidArgumentException |
||
45 | * @return bool|int |
||
46 | */ |
||
47 | public function scoreArgument($argument) |
||
69 | |||
70 | /** |
||
71 | * Returns false. |
||
72 | * |
||
73 | * @return boolean |
||
74 | */ |
||
75 | public function isLast() |
||
79 | |||
80 | /** |
||
81 | * Returns string representation for token. |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function __toString() |
||
89 | |||
90 | /** |
||
91 | * Returns key |
||
92 | * |
||
93 | * @return TokenInterface |
||
94 | */ |
||
95 | public function getKey() |
||
99 | |||
100 | /** |
||
101 | * Returns value |
||
102 | * |
||
103 | * @return TokenInterface |
||
104 | */ |
||
105 | public function getValue() |
||
109 | |||
110 | /** |
||
111 | * Wraps non token $value into ExactValueToken |
||
112 | * |
||
113 | * @param $value |
||
114 | * @return TokenInterface |
||
115 | */ |
||
116 | private function wrapIntoExactValueToken($value) |
||
120 | |||
121 | /** |
||
122 | * Converts instance of \ArrayAccess to key => value array entry |
||
123 | * |
||
124 | * @param \ArrayAccess $object |
||
125 | * |
||
126 | * @return array|null |
||
127 | * @throws \Prophecy\Exception\InvalidArgumentException |
||
128 | */ |
||
129 | private function convertArrayAccessToEntry(\ArrayAccess $object) |
||
143 | } |
||
144 |