Drupal investigation

CombinedSelectorNode.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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\Node;
  11. /**
  12. * Represents a combined node.
  13. *
  14. * This component is a port of the Python cssselect library,
  15. * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
  16. *
  17. * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
  18. *
  19. * @internal
  20. */
  21. class CombinedSelectorNode extends AbstractNode
  22. {
  23. /**
  24. * @var NodeInterface
  25. */
  26. private $selector;
  27. /**
  28. * @var string
  29. */
  30. private $combinator;
  31. /**
  32. * @var NodeInterface
  33. */
  34. private $subSelector;
  35. /**
  36. * @param NodeInterface $selector
  37. * @param string $combinator
  38. * @param NodeInterface $subSelector
  39. */
  40. public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector)
  41. {
  42. $this->selector = $selector;
  43. $this->combinator = $combinator;
  44. $this->subSelector = $subSelector;
  45. }
  46. /**
  47. * @return NodeInterface
  48. */
  49. public function getSelector()
  50. {
  51. return $this->selector;
  52. }
  53. /**
  54. * @return string
  55. */
  56. public function getCombinator()
  57. {
  58. return $this->combinator;
  59. }
  60. /**
  61. * @return NodeInterface
  62. */
  63. public function getSubSelector()
  64. {
  65. return $this->subSelector;
  66. }
  67. /**
  68. * {@inheritdoc}
  69. */
  70. public function getSpecificity()
  71. {
  72. return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
  73. }
  74. /**
  75. * {@inheritdoc}
  76. */
  77. public function __toString()
  78. {
  79. $combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator;
  80. return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector);
  81. }
  82. }