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
AttributeNode.php
49 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\CssSelector\Node; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | class AttributeNode extends AbstractNode |
| 5 | { |
| 6 | private $selector; |
| 7 | private $namespace; |
| 8 | private $attribute; |
| 9 | private $operator; |
| 10 | private $value; |
| 11 | public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value) |
| 12 | { |
| 13 | $this->selector = $selector; |
| 14 | $this->namespace = $namespace; |
| 15 | $this->attribute = $attribute; |
| 16 | $this->operator = $operator; |
| 17 | $this->value = $value; |
| 18 | } |
| 19 | public function getSelector() : NodeInterface |
| 20 | { |
| 21 | return $this->selector; |
| 22 | } |
| 23 | public function getNamespace() : ?string |
| 24 | { |
| 25 | return $this->namespace; |
| 26 | } |
| 27 | public function getAttribute() : string |
| 28 | { |
| 29 | return $this->attribute; |
| 30 | } |
| 31 | public function getOperator() : string |
| 32 | { |
| 33 | return $this->operator; |
| 34 | } |
| 35 | public function getValue() : ?string |
| 36 | { |
| 37 | return $this->value; |
| 38 | } |
| 39 | public function getSpecificity() : Specificity |
| 40 | { |
| 41 | return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
| 42 | } |
| 43 | public function __toString() : string |
| 44 | { |
| 45 | $attribute = $this->namespace ? $this->namespace . '|' . $this->attribute : $this->attribute; |
| 46 | return 'exists' === $this->operator ? \sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute) : \sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value); |
| 47 | } |
| 48 | } |
| 49 |