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
27 private $pseudoElement;
30 * @param NodeInterface $tree
31 * @param string|null $pseudoElement
33 public function __construct(NodeInterface $tree, $pseudoElement = null)
36 $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null;
40 * @return NodeInterface
42 public function getTree()
50 public function getPseudoElement()
52 return $this->pseudoElement;
58 public function getSpecificity()
60 return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0));
66 public function __toString()
68 return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : '');