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
SelectorNode.php
52 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 "<selector>(::|:)<pseudoElement>" 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 SelectorNode extends AbstractNode |
| 24 | { |
| 25 | private $tree; |
| 26 | private $pseudoElement; |
| 27 | public function __construct(NodeInterface $tree, ?string $pseudoElement = null) |
| 28 | { |
| 29 | $this->tree = $tree; |
| 30 | $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null; |
| 31 | } |
| 32 | public function getTree(): NodeInterface |
| 33 | { |
| 34 | return $this->tree; |
| 35 | } |
| 36 | public function getPseudoElement(): ?string |
| 37 | { |
| 38 | return $this->pseudoElement; |
| 39 | } |
| 40 | /** |
| 41 | * {@inheritdoc} |
| 42 | */ |
| 43 | public function getSpecificity(): Specificity |
| 44 | { |
| 45 | return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); |
| 46 | } |
| 47 | public function __toString(): string |
| 48 | { |
| 49 | return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::' . $this->pseudoElement : ''); |
| 50 | } |
| 51 | } |
| 52 |