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