You are here

class IdenticalValueToken in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/src/Prophecy/Argument/Token/IdenticalValueToken.php \Prophecy\Argument\Token\IdenticalValueToken

Identical value token.

@author Florian Voutzinos <florian@voutzinos.com>

Hierarchy

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;
  private $string;
  private $util;

  /**
   * Initializes token.
   *
   * @param mixed      $value
   * @param StringUtil $util
   */
  public function __construct($value, StringUtil $util = null) {
    $this->value = $value;
    $this->util = $util ?: new StringUtil();
  }

  /**
   * Scores 11 if argument matches preset value.
   *
   * @param $argument
   *
   * @return bool|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

Namesort descending Modifiers Type Description Overrides
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