4 * This file is part of the Prophecy.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6 * Marcello Duarte <marcello.duarte@gmail.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Prophecy\Argument\Token;
15 * Array every entry token.
17 * @author Adrien Brault <adrien.brault@gmail.com>
19 class ArrayEveryEntryToken implements TokenInterface
27 * @param mixed $value exact value or token
29 public function __construct($value)
31 if (!$value instanceof TokenInterface) {
32 $value = new ExactValueToken($value);
35 $this->value = $value;
41 public function scoreArgument($argument)
43 if (!$argument instanceof \Traversable && !is_array($argument)) {
48 foreach ($argument as $key => $argumentEntry) {
49 $scores[] = $this->value->scoreArgument($argumentEntry);
52 if (empty($scores) || in_array(false, $scores, true)) {
56 return array_sum($scores) / count($scores);
62 public function isLast()
70 public function __toString()
72 return sprintf('[%s, ..., %s]', $this->value, $this->value);
76 * @return TokenInterface
78 public function getValue()