function ObjectStateToken::scoreArgument
Scores 8 if argument is an object, which method returns expected value.
Parameters
mixed $argument:
Return value
bool|int
Overrides TokenInterface::scoreArgument
File
-
vendor/
phpspec/ prophecy/ src/ Prophecy/ Argument/ Token/ ObjectStateToken.php, line 57
Class
- ObjectStateToken
- Object state-checker token.
Namespace
Prophecy\Argument\TokenCode
public function scoreArgument($argument) {
$methodCallable = array(
$argument,
$this->name,
);
if (is_object($argument) && method_exists($argument, $this->name) && is_callable($methodCallable)) {
$actual = call_user_func($methodCallable);
$comparator = $this->comparatorFactory
->getComparatorFor($this->value, $actual);
try {
$comparator->assertEquals($this->value, $actual);
return 8;
} catch (ComparisonFailure $failure) {
return false;
}
}
if (is_object($argument) && property_exists($argument, $this->name)) {
return $argument->{$this->name} === $this->value ? 8 : false;
}
return false;
}