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

Breadcrumb

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

function ExactValueToken::scoreArgument

Scores 10 if argument matches preset value.

Parameters

mixed $argument:

Return value

false|int

Overrides TokenInterface::scoreArgument

File

vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php, line 54

Class

ExactValueToken
Exact value token.

Namespace

Prophecy\Argument\Token

Code

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) {
            return false;
        }
    }
    // 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;
        }
        if (is_numeric($argument) xor is_numeric($this->value)) {
            return strval($argument) == strval($this->value) ? 10 : false;
        }
    }
    elseif (is_numeric($argument) && is_numeric($this->value)) {
        // noop
    }
    elseif (gettype($argument) !== gettype($this->value)) {
        return false;
    }
    return $argument == $this->value ? 10 : false;
}

API Navigation

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