CommentHandler.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\CssSelector\Parser\Handler;
  11. use Symfony\Component\CssSelector\Parser\Reader;
  12. use Symfony\Component\CssSelector\Parser\TokenStream;
  13. /**
  14. * CSS selector comment handler.
  15. *
  16. * This component is a port of the Python cssselect library,
  17. * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
  18. *
  19. * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
  20. *
  21. * @internal
  22. */
  23. class CommentHandler implements HandlerInterface
  24. {
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function handle(Reader $reader, TokenStream $stream)
  29. {
  30. if ('/*' !== $reader->getSubstring(2)) {
  31. return false;
  32. }
  33. $offset = $reader->getOffset('*/');
  34. if (false === $offset) {
  35. $reader->moveToEnd();
  36. } else {
  37. $reader->moveForward($offset + 2);
  38. }
  39. return true;
  40. }
  41. }