You are here

public function ObjectStateToken::scoreArgument in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ObjectStateToken.php \Prophecy\Argument\Token\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 58

Class

ObjectStateToken
Object state-checker token.

Namespace

Prophecy\Argument\Token

Code

public function scoreArgument($argument) {
  if (is_object($argument) && method_exists($argument, $this->name)) {
    $actual = call_user_func(array(
      $argument,
      $this->name,
    ));
    $comparator = $this->comparatorFactory
      ->getComparatorFor($actual, $this->value);
    try {
      $comparator
        ->assertEquals($actual, $this->value);
      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;
}