public function ExactValueToken::scoreArgument in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php \Prophecy\Argument\Token\ExactValueToken::scoreArgument()
Scores 10 if argument matches preset value.
Parameters
$argument:
Return value
bool|int
Overrides TokenInterface::scoreArgument
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Argument/ Token/ ExactValueToken.php, line 52
Class
- ExactValueToken
- Exact value token.
Namespace
Prophecy\Argument\TokenCode
public function scoreArgument($argument) {
if (is_object($argument) && is_object($this->value)) {
$comparator = $this->comparatorFactory
->getComparatorFor($argument, $this->value);
try {
$comparator
->assertEquals($argument, $this->value);
return 10;
} catch (ComparisonFailure $failure) {
}
}
// If either one is an object it should be castable to a string
if (is_object($argument) xor is_object($this->value)) {
if (is_object($argument) && !method_exists($argument, '__toString')) {
return false;
}
if (is_object($this->value) && !method_exists($this->value, '__toString')) {
return false;
}
}
elseif (is_numeric($argument) && is_numeric($this->value)) {
// noop
}
elseif (gettype($argument) !== gettype($this->value)) {
return false;
}
return $argument == $this->value ? 10 : false;
}