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;
17 * @author Boris Mikhaylov <kaguxmail@gmail.com>
19 class LogicalAndToken implements TokenInterface
21 private $tokens = array();
24 * @param array $arguments exact values or tokens
26 public function __construct(array $arguments)
28 foreach ($arguments as $argument) {
29 if (!$argument instanceof TokenInterface) {
30 $argument = new ExactValueToken($argument);
32 $this->tokens[] = $argument;
37 * Scores maximum score from scores returned by tokens for this argument if all of them score.
43 public function scoreArgument($argument)
45 if (0 === count($this->tokens)) {
50 foreach ($this->tokens as $token) {
51 $score = $token->scoreArgument($argument);
52 if (false === $score) {
55 $maxScore = max($score, $maxScore);
66 public function isLast()
72 * Returns string representation for token.
76 public function __toString()
78 return sprintf('bool(%s)', implode(' AND ', $this->tokens));