You are here

class Token in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/css-selector/Parser/Token.php \Symfony\Component\CssSelector\Parser\Token
  2. 8 core/lib/Drupal/Core/Utility/Token.php \Drupal\Core\Utility\Token
  3. 8 core/lib/Drupal/Core/Render/Element/Token.php \Drupal\Core\Render\Element\Token
Same name and namespace in other branches
  1. 8.0 vendor/symfony/css-selector/Parser/Token.php \Symfony\Component\CssSelector\Parser\Token

CSS selector token.

This component is a port of the Python cssselect library, which is copyright Ian Bicking, @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>

Hierarchy

  • class \Symfony\Component\CssSelector\Parser\Token

Expanded class hierarchy of Token

See also

https://github.com/SimonSapin/cssselect.

18 files declare their use of Token
AbstractHandlerTest.php in vendor/symfony/css-selector/Tests/Parser/Handler/AbstractHandlerTest.php
CommentHandlerTest.php in vendor/symfony/css-selector/Tests/Parser/Handler/CommentHandlerTest.php
FunctionNode.php in vendor/symfony/css-selector/Node/FunctionNode.php
FunctionNodeTest.php in vendor/symfony/css-selector/Tests/Node/FunctionNodeTest.php
HashHandler.php in vendor/symfony/css-selector/Parser/Handler/HashHandler.php

... See full list

File

vendor/symfony/css-selector/Parser/Token.php, line 22

Namespace

Symfony\Component\CssSelector\Parser
View source
class Token {
  const TYPE_FILE_END = 'eof';
  const TYPE_DELIMITER = 'delimiter';
  const TYPE_WHITESPACE = 'whitespace';
  const TYPE_IDENTIFIER = 'identifier';
  const TYPE_HASH = 'hash';
  const TYPE_NUMBER = 'number';
  const TYPE_STRING = 'string';

  /**
   * @var int
   */
  private $type;

  /**
   * @var string
   */
  private $value;

  /**
   * @var int
   */
  private $position;

  /**
   * @param int    $type
   * @param string $value
   * @param int    $position
   */
  public function __construct($type, $value, $position) {
    $this->type = $type;
    $this->value = $value;
    $this->position = $position;
  }

  /**
   * @return int
   */
  public function getType() {
    return $this->type;
  }

  /**
   * @return string
   */
  public function getValue() {
    return $this->value;
  }

  /**
   * @return int
   */
  public function getPosition() {
    return $this->position;
  }

  /**
   * @return bool
   */
  public function isFileEnd() {
    return self::TYPE_FILE_END === $this->type;
  }

  /**
   * @param array $values
   *
   * @return bool
   */
  public function isDelimiter(array $values = array()) {
    if (self::TYPE_DELIMITER !== $this->type) {
      return false;
    }
    if (empty($values)) {
      return true;
    }
    return in_array($this->value, $values);
  }

  /**
   * @return bool
   */
  public function isWhitespace() {
    return self::TYPE_WHITESPACE === $this->type;
  }

  /**
   * @return bool
   */
  public function isIdentifier() {
    return self::TYPE_IDENTIFIER === $this->type;
  }

  /**
   * @return bool
   */
  public function isHash() {
    return self::TYPE_HASH === $this->type;
  }

  /**
   * @return bool
   */
  public function isNumber() {
    return self::TYPE_NUMBER === $this->type;
  }

  /**
   * @return bool
   */
  public function isString() {
    return self::TYPE_STRING === $this->type;
  }

  /**
   * @return string
   */
  public function __toString() {
    if ($this->value) {
      return sprintf('<%s "%s" at %s>', $this->type, $this->value, $this->position);
    }
    return sprintf('<%s at %s>', $this->type, $this->position);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Token::$position private property
Token::$type private property
Token::$value private property
Token::getPosition public function
Token::getType public function
Token::getValue public function
Token::isDelimiter public function
Token::isFileEnd public function
Token::isHash public function
Token::isIdentifier public function
Token::isNumber public function
Token::isString public function
Token::isWhitespace public function
Token::TYPE_DELIMITER constant
Token::TYPE_FILE_END constant
Token::TYPE_HASH constant
Token::TYPE_IDENTIFIER constant
Token::TYPE_NUMBER constant
Token::TYPE_STRING constant
Token::TYPE_WHITESPACE constant
Token::__construct public function
Token::__toString public function