123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace Symfony\Component\CssSelector\Node;
- class AttributeNode extends AbstractNode
- {
- private $selector;
- private $namespace;
- private $attribute;
- private $operator;
- private $value;
-
- public function __construct(NodeInterface $selector, $namespace, $attribute, $operator, $value)
- {
- $this->selector = $selector;
- $this->namespace = $namespace;
- $this->attribute = $attribute;
- $this->operator = $operator;
- $this->value = $value;
- }
-
- public function getSelector()
- {
- return $this->selector;
- }
-
- public function getNamespace()
- {
- return $this->namespace;
- }
-
- public function getAttribute()
- {
- return $this->attribute;
- }
-
- public function getOperator()
- {
- return $this->operator;
- }
-
- public function getValue()
- {
- return $this->value;
- }
-
- public function getSpecificity()
- {
- return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
- }
-
- public function __toString()
- {
- $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute;
- 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);
- }
- }
|