@@ -26,44 +26,44 @@ |
||
26 | 26 | */ |
27 | 27 | class CssSelectorConverter |
28 | 28 | { |
29 | - private $translator; |
|
30 | - private $cache; |
|
29 | + private $translator; |
|
30 | + private $cache; |
|
31 | 31 | |
32 | - private static $xmlCache = []; |
|
33 | - private static $htmlCache = []; |
|
32 | + private static $xmlCache = []; |
|
33 | + private static $htmlCache = []; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param bool $html Whether HTML support should be enabled. Disable it for XML documents |
|
37 | - */ |
|
38 | - public function __construct(bool $html = true) |
|
39 | - { |
|
40 | - $this->translator = new Translator(); |
|
35 | + /** |
|
36 | + * @param bool $html Whether HTML support should be enabled. Disable it for XML documents |
|
37 | + */ |
|
38 | + public function __construct(bool $html = true) |
|
39 | + { |
|
40 | + $this->translator = new Translator(); |
|
41 | 41 | |
42 | - if ($html) { |
|
43 | - $this->translator->registerExtension(new HtmlExtension($this->translator)); |
|
44 | - $this->cache = &self::$htmlCache; |
|
45 | - } else { |
|
46 | - $this->cache = &self::$xmlCache; |
|
47 | - } |
|
42 | + if ($html) { |
|
43 | + $this->translator->registerExtension(new HtmlExtension($this->translator)); |
|
44 | + $this->cache = &self::$htmlCache; |
|
45 | + } else { |
|
46 | + $this->cache = &self::$xmlCache; |
|
47 | + } |
|
48 | 48 | |
49 | - $this->translator |
|
50 | - ->registerParserShortcut(new EmptyStringParser()) |
|
51 | - ->registerParserShortcut(new ElementParser()) |
|
52 | - ->registerParserShortcut(new ClassParser()) |
|
53 | - ->registerParserShortcut(new HashParser()) |
|
54 | - ; |
|
55 | - } |
|
49 | + $this->translator |
|
50 | + ->registerParserShortcut(new EmptyStringParser()) |
|
51 | + ->registerParserShortcut(new ElementParser()) |
|
52 | + ->registerParserShortcut(new ClassParser()) |
|
53 | + ->registerParserShortcut(new HashParser()) |
|
54 | + ; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Translates a CSS expression to its XPath equivalent. |
|
59 | - * |
|
60 | - * Optionally, a prefix can be added to the resulting XPath |
|
61 | - * expression with the $prefix parameter. |
|
62 | - * |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::') |
|
66 | - { |
|
67 | - return $this->cache[$prefix][$cssExpr] ?? $this->cache[$prefix][$cssExpr] = $this->translator->cssToXPath($cssExpr, $prefix); |
|
68 | - } |
|
57 | + /** |
|
58 | + * Translates a CSS expression to its XPath equivalent. |
|
59 | + * |
|
60 | + * Optionally, a prefix can be added to the resulting XPath |
|
61 | + * expression with the $prefix parameter. |
|
62 | + * |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::') |
|
66 | + { |
|
67 | + return $this->cache[$prefix][$cssExpr] ?? $this->cache[$prefix][$cssExpr] = $this->translator->cssToXPath($cssExpr, $prefix); |
|
68 | + } |
|
69 | 69 | } |
@@ -25,49 +25,49 @@ |
||
25 | 25 | */ |
26 | 26 | class Specificity |
27 | 27 | { |
28 | - public const A_FACTOR = 100; |
|
29 | - public const B_FACTOR = 10; |
|
30 | - public const C_FACTOR = 1; |
|
28 | + public const A_FACTOR = 100; |
|
29 | + public const B_FACTOR = 10; |
|
30 | + public const C_FACTOR = 1; |
|
31 | 31 | |
32 | - private $a; |
|
33 | - private $b; |
|
34 | - private $c; |
|
32 | + private $a; |
|
33 | + private $b; |
|
34 | + private $c; |
|
35 | 35 | |
36 | - public function __construct(int $a, int $b, int $c) |
|
37 | - { |
|
38 | - $this->a = $a; |
|
39 | - $this->b = $b; |
|
40 | - $this->c = $c; |
|
41 | - } |
|
36 | + public function __construct(int $a, int $b, int $c) |
|
37 | + { |
|
38 | + $this->a = $a; |
|
39 | + $this->b = $b; |
|
40 | + $this->c = $c; |
|
41 | + } |
|
42 | 42 | |
43 | - public function plus(self $specificity): self |
|
44 | - { |
|
45 | - return new self($this->a + $specificity->a, $this->b + $specificity->b, $this->c + $specificity->c); |
|
46 | - } |
|
43 | + public function plus(self $specificity): self |
|
44 | + { |
|
45 | + return new self($this->a + $specificity->a, $this->b + $specificity->b, $this->c + $specificity->c); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getValue(): int |
|
49 | - { |
|
50 | - return $this->a * self::A_FACTOR + $this->b * self::B_FACTOR + $this->c * self::C_FACTOR; |
|
51 | - } |
|
48 | + public function getValue(): int |
|
49 | + { |
|
50 | + return $this->a * self::A_FACTOR + $this->b * self::B_FACTOR + $this->c * self::C_FACTOR; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Returns -1 if the object specificity is lower than the argument, |
|
55 | - * 0 if they are equal, and 1 if the argument is lower. |
|
56 | - */ |
|
57 | - public function compareTo(self $specificity): int |
|
58 | - { |
|
59 | - if ($this->a !== $specificity->a) { |
|
60 | - return $this->a > $specificity->a ? 1 : -1; |
|
61 | - } |
|
53 | + /** |
|
54 | + * Returns -1 if the object specificity is lower than the argument, |
|
55 | + * 0 if they are equal, and 1 if the argument is lower. |
|
56 | + */ |
|
57 | + public function compareTo(self $specificity): int |
|
58 | + { |
|
59 | + if ($this->a !== $specificity->a) { |
|
60 | + return $this->a > $specificity->a ? 1 : -1; |
|
61 | + } |
|
62 | 62 | |
63 | - if ($this->b !== $specificity->b) { |
|
64 | - return $this->b > $specificity->b ? 1 : -1; |
|
65 | - } |
|
63 | + if ($this->b !== $specificity->b) { |
|
64 | + return $this->b > $specificity->b ? 1 : -1; |
|
65 | + } |
|
66 | 66 | |
67 | - if ($this->c !== $specificity->c) { |
|
68 | - return $this->c > $specificity->c ? 1 : -1; |
|
69 | - } |
|
67 | + if ($this->c !== $specificity->c) { |
|
68 | + return $this->c > $specificity->c ? 1 : -1; |
|
69 | + } |
|
70 | 70 | |
71 | - return 0; |
|
72 | - } |
|
71 | + return 0; |
|
72 | + } |
|
73 | 73 | } |
@@ -23,17 +23,17 @@ |
||
23 | 23 | */ |
24 | 24 | abstract class AbstractNode implements NodeInterface |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - private $nodeName; |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + private $nodeName; |
|
30 | 30 | |
31 | - public function getNodeName(): string |
|
32 | - { |
|
33 | - if (null === $this->nodeName) { |
|
34 | - $this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', static::class); |
|
35 | - } |
|
31 | + public function getNodeName(): string |
|
32 | + { |
|
33 | + if (null === $this->nodeName) { |
|
34 | + $this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', static::class); |
|
35 | + } |
|
36 | 36 | |
37 | - return $this->nodeName; |
|
38 | - } |
|
37 | + return $this->nodeName; |
|
38 | + } |
|
39 | 39 | } |
@@ -23,37 +23,37 @@ |
||
23 | 23 | */ |
24 | 24 | class ElementNode extends AbstractNode |
25 | 25 | { |
26 | - private $namespace; |
|
27 | - private $element; |
|
28 | - |
|
29 | - public function __construct(string $namespace = null, string $element = null) |
|
30 | - { |
|
31 | - $this->namespace = $namespace; |
|
32 | - $this->element = $element; |
|
33 | - } |
|
34 | - |
|
35 | - public function getNamespace(): ?string |
|
36 | - { |
|
37 | - return $this->namespace; |
|
38 | - } |
|
39 | - |
|
40 | - public function getElement(): ?string |
|
41 | - { |
|
42 | - return $this->element; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getSpecificity(): Specificity |
|
49 | - { |
|
50 | - return new Specificity(0, 0, $this->element ? 1 : 0); |
|
51 | - } |
|
52 | - |
|
53 | - public function __toString(): string |
|
54 | - { |
|
55 | - $element = $this->element ?: '*'; |
|
56 | - |
|
57 | - return sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element); |
|
58 | - } |
|
26 | + private $namespace; |
|
27 | + private $element; |
|
28 | + |
|
29 | + public function __construct(string $namespace = null, string $element = null) |
|
30 | + { |
|
31 | + $this->namespace = $namespace; |
|
32 | + $this->element = $element; |
|
33 | + } |
|
34 | + |
|
35 | + public function getNamespace(): ?string |
|
36 | + { |
|
37 | + return $this->namespace; |
|
38 | + } |
|
39 | + |
|
40 | + public function getElement(): ?string |
|
41 | + { |
|
42 | + return $this->element; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getSpecificity(): Specificity |
|
49 | + { |
|
50 | + return new Specificity(0, 0, $this->element ? 1 : 0); |
|
51 | + } |
|
52 | + |
|
53 | + public function __toString(): string |
|
54 | + { |
|
55 | + $element = $this->element ?: '*'; |
|
56 | + |
|
57 | + return sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element); |
|
58 | + } |
|
59 | 59 | } |
@@ -23,35 +23,35 @@ |
||
23 | 23 | */ |
24 | 24 | class PseudoNode extends AbstractNode |
25 | 25 | { |
26 | - private $selector; |
|
27 | - private $identifier; |
|
28 | - |
|
29 | - public function __construct(NodeInterface $selector, string $identifier) |
|
30 | - { |
|
31 | - $this->selector = $selector; |
|
32 | - $this->identifier = strtolower($identifier); |
|
33 | - } |
|
34 | - |
|
35 | - public function getSelector(): NodeInterface |
|
36 | - { |
|
37 | - return $this->selector; |
|
38 | - } |
|
39 | - |
|
40 | - public function getIdentifier(): string |
|
41 | - { |
|
42 | - return $this->identifier; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getSpecificity(): Specificity |
|
49 | - { |
|
50 | - return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
51 | - } |
|
52 | - |
|
53 | - public function __toString(): string |
|
54 | - { |
|
55 | - return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier); |
|
56 | - } |
|
26 | + private $selector; |
|
27 | + private $identifier; |
|
28 | + |
|
29 | + public function __construct(NodeInterface $selector, string $identifier) |
|
30 | + { |
|
31 | + $this->selector = $selector; |
|
32 | + $this->identifier = strtolower($identifier); |
|
33 | + } |
|
34 | + |
|
35 | + public function getSelector(): NodeInterface |
|
36 | + { |
|
37 | + return $this->selector; |
|
38 | + } |
|
39 | + |
|
40 | + public function getIdentifier(): string |
|
41 | + { |
|
42 | + return $this->identifier; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getSpecificity(): Specificity |
|
49 | + { |
|
50 | + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
51 | + } |
|
52 | + |
|
53 | + public function __toString(): string |
|
54 | + { |
|
55 | + return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier); |
|
56 | + } |
|
57 | 57 | } |
@@ -23,44 +23,44 @@ |
||
23 | 23 | */ |
24 | 24 | class CombinedSelectorNode extends AbstractNode |
25 | 25 | { |
26 | - private $selector; |
|
27 | - private $combinator; |
|
28 | - private $subSelector; |
|
26 | + private $selector; |
|
27 | + private $combinator; |
|
28 | + private $subSelector; |
|
29 | 29 | |
30 | - public function __construct(NodeInterface $selector, string $combinator, NodeInterface $subSelector) |
|
31 | - { |
|
32 | - $this->selector = $selector; |
|
33 | - $this->combinator = $combinator; |
|
34 | - $this->subSelector = $subSelector; |
|
35 | - } |
|
30 | + public function __construct(NodeInterface $selector, string $combinator, NodeInterface $subSelector) |
|
31 | + { |
|
32 | + $this->selector = $selector; |
|
33 | + $this->combinator = $combinator; |
|
34 | + $this->subSelector = $subSelector; |
|
35 | + } |
|
36 | 36 | |
37 | - public function getSelector(): NodeInterface |
|
38 | - { |
|
39 | - return $this->selector; |
|
40 | - } |
|
37 | + public function getSelector(): NodeInterface |
|
38 | + { |
|
39 | + return $this->selector; |
|
40 | + } |
|
41 | 41 | |
42 | - public function getCombinator(): string |
|
43 | - { |
|
44 | - return $this->combinator; |
|
45 | - } |
|
42 | + public function getCombinator(): string |
|
43 | + { |
|
44 | + return $this->combinator; |
|
45 | + } |
|
46 | 46 | |
47 | - public function getSubSelector(): NodeInterface |
|
48 | - { |
|
49 | - return $this->subSelector; |
|
50 | - } |
|
47 | + public function getSubSelector(): NodeInterface |
|
48 | + { |
|
49 | + return $this->subSelector; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * {@inheritdoc} |
|
54 | - */ |
|
55 | - public function getSpecificity(): Specificity |
|
56 | - { |
|
57 | - return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); |
|
58 | - } |
|
52 | + /** |
|
53 | + * {@inheritdoc} |
|
54 | + */ |
|
55 | + public function getSpecificity(): Specificity |
|
56 | + { |
|
57 | + return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); |
|
58 | + } |
|
59 | 59 | |
60 | - public function __toString(): string |
|
61 | - { |
|
62 | - $combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator; |
|
60 | + public function __toString(): string |
|
61 | + { |
|
62 | + $combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator; |
|
63 | 63 | |
64 | - return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector); |
|
65 | - } |
|
64 | + return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector); |
|
65 | + } |
|
66 | 66 | } |
@@ -25,52 +25,52 @@ |
||
25 | 25 | */ |
26 | 26 | class FunctionNode extends AbstractNode |
27 | 27 | { |
28 | - private $selector; |
|
29 | - private $name; |
|
30 | - private $arguments; |
|
28 | + private $selector; |
|
29 | + private $name; |
|
30 | + private $arguments; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param Token[] $arguments |
|
34 | - */ |
|
35 | - public function __construct(NodeInterface $selector, string $name, array $arguments = []) |
|
36 | - { |
|
37 | - $this->selector = $selector; |
|
38 | - $this->name = strtolower($name); |
|
39 | - $this->arguments = $arguments; |
|
40 | - } |
|
32 | + /** |
|
33 | + * @param Token[] $arguments |
|
34 | + */ |
|
35 | + public function __construct(NodeInterface $selector, string $name, array $arguments = []) |
|
36 | + { |
|
37 | + $this->selector = $selector; |
|
38 | + $this->name = strtolower($name); |
|
39 | + $this->arguments = $arguments; |
|
40 | + } |
|
41 | 41 | |
42 | - public function getSelector(): NodeInterface |
|
43 | - { |
|
44 | - return $this->selector; |
|
45 | - } |
|
42 | + public function getSelector(): NodeInterface |
|
43 | + { |
|
44 | + return $this->selector; |
|
45 | + } |
|
46 | 46 | |
47 | - public function getName(): string |
|
48 | - { |
|
49 | - return $this->name; |
|
50 | - } |
|
47 | + public function getName(): string |
|
48 | + { |
|
49 | + return $this->name; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return Token[] |
|
54 | - */ |
|
55 | - public function getArguments(): array |
|
56 | - { |
|
57 | - return $this->arguments; |
|
58 | - } |
|
52 | + /** |
|
53 | + * @return Token[] |
|
54 | + */ |
|
55 | + public function getArguments(): array |
|
56 | + { |
|
57 | + return $this->arguments; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * {@inheritdoc} |
|
62 | - */ |
|
63 | - public function getSpecificity(): Specificity |
|
64 | - { |
|
65 | - return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
66 | - } |
|
60 | + /** |
|
61 | + * {@inheritdoc} |
|
62 | + */ |
|
63 | + public function getSpecificity(): Specificity |
|
64 | + { |
|
65 | + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
66 | + } |
|
67 | 67 | |
68 | - public function __toString(): string |
|
69 | - { |
|
70 | - $arguments = implode(', ', array_map(function (Token $token) { |
|
71 | - return "'".$token->getValue()."'"; |
|
72 | - }, $this->arguments)); |
|
68 | + public function __toString(): string |
|
69 | + { |
|
70 | + $arguments = implode(', ', array_map(function (Token $token) { |
|
71 | + return "'".$token->getValue()."'"; |
|
72 | + }, $this->arguments)); |
|
73 | 73 | |
74 | - return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : ''); |
|
75 | - } |
|
74 | + return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : ''); |
|
75 | + } |
|
76 | 76 | } |
@@ -23,35 +23,35 @@ |
||
23 | 23 | */ |
24 | 24 | class ClassNode extends AbstractNode |
25 | 25 | { |
26 | - private $selector; |
|
27 | - private $name; |
|
28 | - |
|
29 | - public function __construct(NodeInterface $selector, string $name) |
|
30 | - { |
|
31 | - $this->selector = $selector; |
|
32 | - $this->name = $name; |
|
33 | - } |
|
34 | - |
|
35 | - public function getSelector(): NodeInterface |
|
36 | - { |
|
37 | - return $this->selector; |
|
38 | - } |
|
39 | - |
|
40 | - public function getName(): string |
|
41 | - { |
|
42 | - return $this->name; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getSpecificity(): Specificity |
|
49 | - { |
|
50 | - return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
51 | - } |
|
52 | - |
|
53 | - public function __toString(): string |
|
54 | - { |
|
55 | - return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); |
|
56 | - } |
|
26 | + private $selector; |
|
27 | + private $name; |
|
28 | + |
|
29 | + public function __construct(NodeInterface $selector, string $name) |
|
30 | + { |
|
31 | + $this->selector = $selector; |
|
32 | + $this->name = $name; |
|
33 | + } |
|
34 | + |
|
35 | + public function getSelector(): NodeInterface |
|
36 | + { |
|
37 | + return $this->selector; |
|
38 | + } |
|
39 | + |
|
40 | + public function getName(): string |
|
41 | + { |
|
42 | + return $this->name; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getSpecificity(): Specificity |
|
49 | + { |
|
50 | + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
51 | + } |
|
52 | + |
|
53 | + public function __toString(): string |
|
54 | + { |
|
55 | + return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); |
|
56 | + } |
|
57 | 57 | } |
@@ -23,60 +23,60 @@ |
||
23 | 23 | */ |
24 | 24 | class AttributeNode extends AbstractNode |
25 | 25 | { |
26 | - private $selector; |
|
27 | - private $namespace; |
|
28 | - private $attribute; |
|
29 | - private $operator; |
|
30 | - private $value; |
|
26 | + private $selector; |
|
27 | + private $namespace; |
|
28 | + private $attribute; |
|
29 | + private $operator; |
|
30 | + private $value; |
|
31 | 31 | |
32 | - public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value) |
|
33 | - { |
|
34 | - $this->selector = $selector; |
|
35 | - $this->namespace = $namespace; |
|
36 | - $this->attribute = $attribute; |
|
37 | - $this->operator = $operator; |
|
38 | - $this->value = $value; |
|
39 | - } |
|
32 | + public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value) |
|
33 | + { |
|
34 | + $this->selector = $selector; |
|
35 | + $this->namespace = $namespace; |
|
36 | + $this->attribute = $attribute; |
|
37 | + $this->operator = $operator; |
|
38 | + $this->value = $value; |
|
39 | + } |
|
40 | 40 | |
41 | - public function getSelector(): NodeInterface |
|
42 | - { |
|
43 | - return $this->selector; |
|
44 | - } |
|
41 | + public function getSelector(): NodeInterface |
|
42 | + { |
|
43 | + return $this->selector; |
|
44 | + } |
|
45 | 45 | |
46 | - public function getNamespace(): ?string |
|
47 | - { |
|
48 | - return $this->namespace; |
|
49 | - } |
|
46 | + public function getNamespace(): ?string |
|
47 | + { |
|
48 | + return $this->namespace; |
|
49 | + } |
|
50 | 50 | |
51 | - public function getAttribute(): string |
|
52 | - { |
|
53 | - return $this->attribute; |
|
54 | - } |
|
51 | + public function getAttribute(): string |
|
52 | + { |
|
53 | + return $this->attribute; |
|
54 | + } |
|
55 | 55 | |
56 | - public function getOperator(): string |
|
57 | - { |
|
58 | - return $this->operator; |
|
59 | - } |
|
56 | + public function getOperator(): string |
|
57 | + { |
|
58 | + return $this->operator; |
|
59 | + } |
|
60 | 60 | |
61 | - public function getValue(): ?string |
|
62 | - { |
|
63 | - return $this->value; |
|
64 | - } |
|
61 | + public function getValue(): ?string |
|
62 | + { |
|
63 | + return $this->value; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * {@inheritdoc} |
|
68 | - */ |
|
69 | - public function getSpecificity(): Specificity |
|
70 | - { |
|
71 | - return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
72 | - } |
|
66 | + /** |
|
67 | + * {@inheritdoc} |
|
68 | + */ |
|
69 | + public function getSpecificity(): Specificity |
|
70 | + { |
|
71 | + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
72 | + } |
|
73 | 73 | |
74 | - public function __toString(): string |
|
75 | - { |
|
76 | - $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; |
|
74 | + public function __toString(): string |
|
75 | + { |
|
76 | + $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; |
|
77 | 77 | |
78 | - return 'exists' === $this->operator |
|
79 | - ? sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute) |
|
80 | - : sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value); |
|
81 | - } |
|
78 | + return 'exists' === $this->operator |
|
79 | + ? sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute) |
|
80 | + : sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value); |
|
81 | + } |
|
82 | 82 | } |