wp-user-avatar
/
third-party
/
vendor
/
symfony
/
css-selector
/
Parser
/
Handler
/
WhitespaceHandler.php
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
WhitespaceHandler.php
42 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\TokenStream; |
| 16 | /** |
| 17 | * CSS selector whitespace handler. |
| 18 | * |
| 19 | * This component is a port of the Python cssselect library, |
| 20 | * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. |
| 21 | * |
| 22 | * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> |
| 23 | * |
| 24 | * @internal |
| 25 | */ |
| 26 | class WhitespaceHandler implements HandlerInterface |
| 27 | { |
| 28 | /** |
| 29 | * {@inheritdoc} |
| 30 | */ |
| 31 | public function handle(Reader $reader, TokenStream $stream): bool |
| 32 | { |
| 33 | $match = $reader->findPattern('~^[ \t\r\n\f]+~'); |
| 34 | if (\false === $match) { |
| 35 | return \false; |
| 36 | } |
| 37 | $stream->push(new Token(Token::TYPE_WHITESPACE, $match[0], $reader->getPosition())); |
| 38 | $reader->moveForward(\strlen($match[0])); |
| 39 | return \true; |
| 40 | } |
| 41 | } |
| 42 |