Merge pull request #4036 from dokuwiki/issue4033
[dokuwiki.git] / _test / vendor / symfony / css-selector / Node / FunctionNode.php
blobc464cf7c056b626af1d9c0b42726fd457dfd121e
1 <?php
3 /*
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;
16 /**
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>
24 * @internal
26 class FunctionNode extends AbstractNode
28 private $selector;
29 private $name;
30 private $arguments;
32 /**
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
49 return $this->name;
52 /**
53 * @return Token[]
55 public function getArguments(): array
57 return $this->arguments;
60 /**
61 * {@inheritdoc}
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.']' : '');