CommentHandler.php
2 months ago
HandlerInterface.php
2 months ago
HashHandler.php
2 months ago
IdentifierHandler.php
2 months ago
NumberHandler.php
2 months ago
StringHandler.php
2 months ago
WhitespaceHandler.php
2 months ago
HashHandler.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace ProfilePressVendor\Symfony\Component\CssSelector\Parser\Handler; |
| 12 | |
| 13 | use ProfilePressVendor\Symfony\Component\CssSelector\Parser\Reader; |
| 14 | use ProfilePressVendor\Symfony\Component\CssSelector\Parser\Token; |
| 15 | use ProfilePressVendor\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; |
| 16 | use ProfilePressVendor\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; |
| 17 | use ProfilePressVendor\Symfony\Component\CssSelector\Parser\TokenStream; |
| 18 | /** |
| 19 | * CSS selector comment handler. |
| 20 | * |
| 21 | * This component is a port of the Python cssselect library, |
| 22 | * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. |
| 23 | * |
| 24 | * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> |
| 25 | * |
| 26 | * @internal |
| 27 | */ |
| 28 | class HashHandler implements HandlerInterface |
| 29 | { |
| 30 | private $patterns; |
| 31 | private $escaping; |
| 32 | public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) |
| 33 | { |
| 34 | $this->patterns = $patterns; |
| 35 | $this->escaping = $escaping; |
| 36 | } |
| 37 | /** |
| 38 | * {@inheritdoc} |
| 39 | */ |
| 40 | public function handle(Reader $reader, TokenStream $stream): bool |
| 41 | { |
| 42 | $match = $reader->findPattern($this->patterns->getHashPattern()); |
| 43 | if (!$match) { |
| 44 | return \false; |
| 45 | } |
| 46 | $value = $this->escaping->escapeUnicode($match[1]); |
| 47 | $stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition())); |
| 48 | $reader->moveForward(\strlen($match[0])); |
| 49 | return \true; |
| 50 | } |
| 51 | } |
| 52 |