Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ObjectStateToken.php

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\Token

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal