AbstractNode.php
2 years ago
AttributeNode.php
2 years ago
ClassNode.php
2 years ago
CombinedSelectorNode.php
2 years ago
ElementNode.php
2 years ago
FunctionNode.php
2 years ago
HashNode.php
2 years ago
NegationNode.php
2 years ago
NodeInterface.php
2 years ago
PseudoNode.php
2 years ago
SelectorNode.php
2 years ago
Specificity.php
2 years ago
index.php
2 years ago
SelectorNode.php
30 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\CssSelector\Node; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | class SelectorNode extends AbstractNode |
| 5 | { |
| 6 | private $tree; |
| 7 | private $pseudoElement; |
| 8 | public function __construct(NodeInterface $tree, ?string $pseudoElement = null) |
| 9 | { |
| 10 | $this->tree = $tree; |
| 11 | $this->pseudoElement = $pseudoElement ? \strtolower($pseudoElement) : null; |
| 12 | } |
| 13 | public function getTree() : NodeInterface |
| 14 | { |
| 15 | return $this->tree; |
| 16 | } |
| 17 | public function getPseudoElement() : ?string |
| 18 | { |
| 19 | return $this->pseudoElement; |
| 20 | } |
| 21 | public function getSpecificity() : Specificity |
| 22 | { |
| 23 | return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); |
| 24 | } |
| 25 | public function __toString() : string |
| 26 | { |
| 27 | return \sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::' . $this->pseudoElement : ''); |
| 28 | } |
| 29 | } |
| 30 |