class ArrayEveryEntryToken in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ArrayEveryEntryToken.php \Prophecy\Argument\Token\ArrayEveryEntryToken
Array every entry token.
@author Adrien Brault <adrien.brault@gmail.com>
Hierarchy
- class \Prophecy\Argument\Token\ArrayEveryEntryToken implements TokenInterface
Expanded class hierarchy of ArrayEveryEntryToken
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Argument/ Token/ ArrayEveryEntryToken.php, line 19
Namespace
Prophecy\Argument\TokenView source
class ArrayEveryEntryToken implements TokenInterface {
/**
* @var TokenInterface
*/
private $value;
/**
* @param mixed $value exact value or token
*/
public function __construct($value) {
if (!$value instanceof TokenInterface) {
$value = new ExactValueToken($value);
}
$this->value = $value;
}
/**
* {@inheritdoc}
*/
public function scoreArgument($argument) {
if (!$argument instanceof \Traversable && !is_array($argument)) {
return false;
}
$scores = array();
foreach ($argument as $key => $argumentEntry) {
$scores[] = $this->value
->scoreArgument($argumentEntry);
}
if (empty($scores) || in_array(false, $scores, true)) {
return false;
}
return array_sum($scores) / count($scores);
}
/**
* {@inheritdoc}
*/
public function isLast() {
return false;
}
/**
* {@inheritdoc}
*/
public function __toString() {
return sprintf('[%s, ..., %s]', $this->value, $this->value);
}
/**
* @return TokenInterface
*/
public function getValue() {
return $this->value;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ArrayEveryEntryToken:: |
private | property | ||
ArrayEveryEntryToken:: |
public | function | ||
ArrayEveryEntryToken:: |
public | function |
Returns true if this token prevents check of other tokens (is last one). Overrides TokenInterface:: |
|
ArrayEveryEntryToken:: |
public | function |
Calculates token match score for provided argument. Overrides TokenInterface:: |
|
ArrayEveryEntryToken:: |
public | function | ||
ArrayEveryEntryToken:: |
public | function |
Returns string representation for token. Overrides TokenInterface:: |