comparison vendor/symfony/css-selector/Node/CombinedSelectorNode.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 /**
15 * Represents a combined node.
16 *
17 * This component is a port of the Python cssselect library,
18 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
19 *
20 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
21 *
22 * @internal
23 */
24 class CombinedSelectorNode extends AbstractNode
25 {
26 /**
27 * @var NodeInterface
28 */
29 private $selector;
30
31 /**
32 * @var string
33 */
34 private $combinator;
35
36 /**
37 * @var NodeInterface
38 */
39 private $subSelector;
40
41 /**
42 * @param NodeInterface $selector
43 * @param string $combinator
44 * @param NodeInterface $subSelector
45 */
46 public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector)
47 {
48 $this->selector = $selector;
49 $this->combinator = $combinator;
50 $this->subSelector = $subSelector;
51 }
52
53 /**
54 * @return NodeInterface
55 */
56 public function getSelector()
57 {
58 return $this->selector;
59 }
60
61 /**
62 * @return string
63 */
64 public function getCombinator()
65 {
66 return $this->combinator;
67 }
68
69 /**
70 * @return NodeInterface
71 */
72 public function getSubSelector()
73 {
74 return $this->subSelector;
75 }
76
77 /**
78 * {@inheritdoc}
79 */
80 public function getSpecificity()
81 {
82 return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
83 }
84
85 /**
86 * {@inheritdoc}
87 */
88 public function __toString()
89 {
90 $combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator;
91
92 return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector);
93 }
94 }