You are here

class HashHandler in Zircon Profile 8.0

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

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 HashHandler

See also

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

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

File

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

Namespace

Symfony\Component\CssSelector\Parser\Handler
View source
class HashHandler 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
      ->getHashPattern());
    if (!$match) {
      return false;
    }
    $value = $this->escaping
      ->escapeUnicode($match[1]);
    $stream
      ->push(new Token(Token::TYPE_HASH, $value, $reader
      ->getPosition()));
    $reader
      ->moveForward(strlen($match[0]));
    return true;
  }

}

Members