Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\CssSelector\Node; Chris@0: Chris@0: /** Chris@0: * Represents a "(::|:)" node. Chris@0: * Chris@0: * This component is a port of the Python cssselect library, Chris@0: * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. Chris@0: * Chris@0: * @author Jean-François Simon Chris@0: * Chris@0: * @internal Chris@0: */ Chris@0: class SelectorNode extends AbstractNode Chris@0: { Chris@0: private $tree; Chris@0: private $pseudoElement; Chris@0: Chris@0: /** Chris@0: * @param NodeInterface $tree Chris@17: * @param string|null $pseudoElement Chris@0: */ Chris@0: public function __construct(NodeInterface $tree, $pseudoElement = null) Chris@0: { Chris@0: $this->tree = $tree; Chris@0: $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return NodeInterface Chris@0: */ Chris@0: public function getTree() Chris@0: { Chris@0: return $this->tree; Chris@0: } Chris@0: Chris@0: /** Chris@17: * @return string|null Chris@0: */ Chris@0: public function getPseudoElement() Chris@0: { Chris@0: return $this->pseudoElement; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getSpecificity() Chris@0: { Chris@0: return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function __toString() Chris@0: { Chris@0: return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : ''); Chris@0: } Chris@0: }