AbstractNode.php
2 months ago
AttributeNode.php
2 months ago
ClassNode.php
2 months ago
CombinedSelectorNode.php
2 months ago
ElementNode.php
2 months ago
FunctionNode.php
2 months ago
HashNode.php
2 months ago
NegationNode.php
2 months ago
NodeInterface.php
2 months ago
PseudoNode.php
2 months ago
SelectorNode.php
2 months ago
Specificity.php
2 months ago
CombinedSelectorNode.php
59 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\Node; |
| 12 | |
| 13 | /** |
| 14 | * Represents a combined node. |
| 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 CombinedSelectorNode extends AbstractNode |
| 24 | { |
| 25 | private $selector; |
| 26 | private $combinator; |
| 27 | private $subSelector; |
| 28 | public function __construct(NodeInterface $selector, string $combinator, NodeInterface $subSelector) |
| 29 | { |
| 30 | $this->selector = $selector; |
| 31 | $this->combinator = $combinator; |
| 32 | $this->subSelector = $subSelector; |
| 33 | } |
| 34 | public function getSelector(): NodeInterface |
| 35 | { |
| 36 | return $this->selector; |
| 37 | } |
| 38 | public function getCombinator(): string |
| 39 | { |
| 40 | return $this->combinator; |
| 41 | } |
| 42 | public function getSubSelector(): NodeInterface |
| 43 | { |
| 44 | return $this->subSelector; |
| 45 | } |
| 46 | /** |
| 47 | * {@inheritdoc} |
| 48 | */ |
| 49 | public function getSpecificity(): Specificity |
| 50 | { |
| 51 | return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); |
| 52 | } |
| 53 | public function __toString(): string |
| 54 | { |
| 55 | $combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator; |
| 56 | return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector); |
| 57 | } |
| 58 | } |
| 59 |