You are here

class NumberHandler in Zircon Profile 8

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

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 NumberHandler

See also

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

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

File

vendor/symfony/css-selector/Parser/Handler/NumberHandler.php, line 27

Namespace

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

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

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

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

}

Members