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
44 * @param NodeInterface $selector
46 * @param Token[] $arguments
48 public function __construct(NodeInterface $selector, $name, array $arguments = array())
50 $this->selector = $selector;
51 $this->name = strtolower($name);
52 $this->arguments = $arguments;
56 * @return NodeInterface
58 public function getSelector()
60 return $this->selector;
66 public function getName()
74 public function getArguments()
76 return $this->arguments;
82 public function getSpecificity()
84 return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
90 public function __toString()
92 $arguments = implode(', ', array_map(function (Token $token) {
93 return "'".$token->getValue()."'";
94 }, $this->arguments));
96 return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : '');