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 HashNode extends AbstractNode Chris@0: { Chris@0: private $selector; Chris@0: private $id; Chris@0: Chris@0: /** Chris@0: * @param NodeInterface $selector Chris@0: * @param string $id Chris@0: */ Chris@0: public function __construct(NodeInterface $selector, $id) Chris@0: { Chris@0: $this->selector = $selector; Chris@0: $this->id = $id; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return NodeInterface Chris@0: */ Chris@0: public function getSelector() Chris@0: { Chris@0: return $this->selector; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return string Chris@0: */ Chris@0: public function getId() Chris@0: { Chris@0: return $this->id; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getSpecificity() Chris@0: { Chris@0: return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 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->selector, $this->id); Chris@0: } Chris@0: }