Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\CssSelector\Parser\Handler; Chris@0: Chris@0: use Symfony\Component\CssSelector\Parser\Reader; Chris@0: use Symfony\Component\CssSelector\Parser\Token; Chris@0: use Symfony\Component\CssSelector\Parser\TokenStream; Chris@0: Chris@0: /** Chris@0: * CSS selector whitespace handler. Chris@0: * Chris@0: * This component is a port of the Python cssselect library, Chris@0: * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. Chris@0: * Chris@0: * @author Jean-François Simon Chris@0: * Chris@0: * @internal Chris@0: */ Chris@0: class WhitespaceHandler implements HandlerInterface Chris@0: { Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function handle(Reader $reader, TokenStream $stream) Chris@0: { Chris@0: $match = $reader->findPattern('~^[ \t\r\n\f]+~'); Chris@0: Chris@0: if (false === $match) { Chris@0: return false; Chris@0: } Chris@0: Chris@0: $stream->push(new Token(Token::TYPE_WHITESPACE, $match[0], $reader->getPosition())); Chris@17: $reader->moveForward(\strlen($match[0])); Chris@0: Chris@0: return true; Chris@0: } Chris@0: }