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

Breadcrumb

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

class IdenticalValueToken

Identical value token.

@author Florian Voutzinos <florian@voutzinos.com>

Hierarchy

  • class \Prophecy\Argument\Token\IdenticalValueToken implements \Prophecy\Argument\Token\TokenInterface

Expanded class hierarchy of IdenticalValueToken

File

vendor/phpspec/prophecy/src/Prophecy/Argument/Token/IdenticalValueToken.php, line 21

Namespace

Prophecy\Argument\Token
View source
class IdenticalValueToken implements TokenInterface {
    private $value;
    
    /**
     * @var string|null
     */
    private $string;
    private $util;
    
    /**
     * Initializes token.
     *
     * @param mixed $value
     */
    public function __construct($value, ?StringUtil $util = null) {
        $this->value = $value;
        $this->util = $util ?: new StringUtil();
    }
    
    /**
     * Scores 11 if argument matches preset value.
     *
     * @param mixed $argument
     *
     * @return false|int
     */
    public function scoreArgument($argument) {
        return $argument === $this->value ? 11 : false;
    }
    
    /**
     * Returns false.
     *
     * @return bool
     */
    public function isLast() {
        return false;
    }
    
    /**
     * Returns string representation for token.
     *
     * @return string
     */
    public function __toString() {
        if (null === $this->string) {
            $this->string = sprintf('identical(%s)', $this->util
                ->stringify($this->value));
        }
        return $this->string;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
IdenticalValueToken::$string private property
IdenticalValueToken::$util private property
IdenticalValueToken::$value private property
IdenticalValueToken::isLast public function Returns false. Overrides TokenInterface::isLast
IdenticalValueToken::scoreArgument public function Scores 11 if argument matches preset value. Overrides TokenInterface::scoreArgument
IdenticalValueToken::__construct public function Initializes token.
IdenticalValueToken::__toString public function Returns string representation for token. Overrides TokenInterface::__toString

API Navigation

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