4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\CssSelector\Node
;
14 use Symfony\Component\CssSelector\Parser\Token
;
17 * Represents a "<selector>:<name>(<arguments>)" node.
19 * This component is a port of the Python cssselect library,
20 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
22 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
26 class FunctionNode
extends AbstractNode
33 * @param Token[] $arguments
35 public function __construct(NodeInterface
$selector, string $name, array $arguments = [])
37 $this->selector
= $selector;
38 $this->name
= strtolower($name);
39 $this->arguments
= $arguments;
42 public function getSelector(): NodeInterface
44 return $this->selector
;
47 public function getName(): string
55 public function getArguments(): array
57 return $this->arguments
;
63 public function getSpecificity(): Specificity
65 return $this->selector
->getSpecificity()->plus(new Specificity(0, 1, 0));
68 public function __toString(): string
70 $arguments = implode(', ', array_map(function (Token
$token) {
71 return "'".$token->getValue()."'";
72 }, $this->arguments
));
74 return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector
, $this->name
, $arguments ?
'['.$arguments.']' : '');