scratch – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
87 office 1 <?php
2  
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11  
12 namespace Symfony\Component\CssSelector\Node;
13  
14 use Symfony\Component\CssSelector\Parser\Token;
15  
16 /**
17 * Represents a "<selector>:<name>(<arguments>)" node.
18 *
19 * This component is a port of the Python cssselect library,
20 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
21 *
22 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
23 *
24 * @internal
25 */
26 class FunctionNode extends AbstractNode
27 {
28 /**
29 * @var NodeInterface
30 */
31 private $selector;
32  
33 /**
34 * @var string
35 */
36 private $name;
37  
38 /**
39 * @var Token[]
40 */
41 private $arguments;
42  
43 /**
44 * @param NodeInterface $selector
45 * @param string $name
46 * @param Token[] $arguments
47 */
48 public function __construct(NodeInterface $selector, $name, array $arguments = array())
49 {
50 $this->selector = $selector;
51 $this->name = strtolower($name);
52 $this->arguments = $arguments;
53 }
54  
55 /**
56 * @return NodeInterface
57 */
58 public function getSelector()
59 {
60 return $this->selector;
61 }
62  
63 /**
64 * @return string
65 */
66 public function getName()
67 {
68 return $this->name;
69 }
70  
71 /**
72 * @return Token[]
73 */
74 public function getArguments()
75 {
76 return $this->arguments;
77 }
78  
79 /**
80 * {@inheritdoc}
81 */
82 public function getSpecificity()
83 {
84 return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
85 }
86  
87 /**
88 * {@inheritdoc}
89 */
90 public function __toString()
91 {
92 $arguments = implode(', ', array_map(function (Token $token) {
93 return "'".$token->getValue()."'";
94 }, $this->arguments));
95  
96 return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : '');
97 }
98 }