You are here

class IdentifierHandler in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/css-selector/Parser/Handler/IdentifierHandler.php \Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler

CSS selector comment handler.

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

Expanded class hierarchy of IdentifierHandler

See also

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

1 file declares its use of IdentifierHandler
IdentifierHandlerTest.php in vendor/symfony/css-selector/Tests/Parser/Handler/IdentifierHandlerTest.php

File

vendor/symfony/css-selector/Parser/Handler/IdentifierHandler.php, line 28

Namespace

Symfony\Component\CssSelector\Parser\Handler
View source
class IdentifierHandler implements HandlerInterface {

  /**
   * @var TokenizerPatterns
   */
  private $patterns;

  /**
   * @var TokenizerEscaping
   */
  private $escaping;

  /**
   * @param TokenizerPatterns $patterns
   * @param TokenizerEscaping $escaping
   */
  public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) {
    $this->patterns = $patterns;
    $this->escaping = $escaping;
  }

  /**
   * {@inheritdoc}
   */
  public function handle(Reader $reader, TokenStream $stream) {
    $match = $reader
      ->findPattern($this->patterns
      ->getIdentifierPattern());
    if (!$match) {
      return false;
    }
    $value = $this->escaping
      ->escapeUnicode($match[0]);
    $stream
      ->push(new Token(Token::TYPE_IDENTIFIER, $value, $reader
      ->getPosition()));
    $reader
      ->moveForward(strlen($match[0]));
    return true;
  }

}

Members