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;
15 * Represents a "<selector>(::|:)<pseudoElement>" node.
17 * This component is a port of the Python cssselect library,
18 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
20 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
24 class SelectorNode extends AbstractNode
34 private $pseudoElement;
37 * @param NodeInterface $tree
38 * @param null|string $pseudoElement
40 public function __construct(NodeInterface $tree, $pseudoElement = null)
43 $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null;
47 * @return NodeInterface
49 public function getTree()
57 public function getPseudoElement()
59 return $this->pseudoElement;
65 public function getSpecificity()
67 return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0));
73 public function __toString()
75 return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : '');