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
FunctionNode.php
40 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\CssSelector\Node; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\CssSelector\Parser\Token; |
| 5 | class FunctionNode extends AbstractNode |
| 6 | { |
| 7 | private $selector; |
| 8 | private $name; |
| 9 | private $arguments; |
| 10 | public function __construct(NodeInterface $selector, string $name, array $arguments = []) |
| 11 | { |
| 12 | $this->selector = $selector; |
| 13 | $this->name = \strtolower($name); |
| 14 | $this->arguments = $arguments; |
| 15 | } |
| 16 | public function getSelector() : NodeInterface |
| 17 | { |
| 18 | return $this->selector; |
| 19 | } |
| 20 | public function getName() : string |
| 21 | { |
| 22 | return $this->name; |
| 23 | } |
| 24 | public function getArguments() : array |
| 25 | { |
| 26 | return $this->arguments; |
| 27 | } |
| 28 | public function getSpecificity() : Specificity |
| 29 | { |
| 30 | return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
| 31 | } |
| 32 | public function __toString() : string |
| 33 | { |
| 34 | $arguments = \implode(', ', \array_map(function (Token $token) { |
| 35 | return "'" . $token->getValue() . "'"; |
| 36 | }, $this->arguments)); |
| 37 | return \sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '[' . $arguments . ']' : ''); |
| 38 | } |
| 39 | } |
| 40 |