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

Breadcrumb

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

class StringContainsToken

String contains token.

@author Peter Mitchell <pete@peterjmit.com>

Hierarchy

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

Expanded class hierarchy of StringContainsToken

File

vendor/phpspec/prophecy/src/Prophecy/Argument/Token/StringContainsToken.php, line 19

Namespace

Prophecy\Argument\Token
View source
class StringContainsToken implements TokenInterface {
    private $value;
    
    /**
     * Initializes token.
     *
     * @param string $value
     */
    public function __construct($value) {
        $this->value = $value;
    }
    public function scoreArgument($argument) {
        return is_string($argument) && strpos($argument, $this->value) !== false ? 6 : false;
    }
    
    /**
     * Returns preset value against which token checks arguments.
     *
     * @return mixed
     */
    public function getValue() {
        return $this->value;
    }
    
    /**
     * Returns false.
     *
     * @return bool
     */
    public function isLast() {
        return false;
    }
    
    /**
     * Returns string representation for token.
     *
     * @return string
     */
    public function __toString() {
        return sprintf('contains("%s")', $this->value);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
StringContainsToken::$value private property
StringContainsToken::getValue public function Returns preset value against which token checks arguments.
StringContainsToken::isLast public function Returns false. Overrides TokenInterface::isLast
StringContainsToken::scoreArgument public function Calculates token match score for provided argument. Overrides TokenInterface::scoreArgument
StringContainsToken::__construct public function Initializes token.
StringContainsToken::__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