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 ElementNode extends AbstractNode Chris@0: { Chris@0: private $namespace; Chris@0: private $element; Chris@0: Chris@0: /** Chris@0: * @param string|null $namespace Chris@0: * @param string|null $element Chris@0: */ Chris@0: public function __construct($namespace = null, $element = null) Chris@0: { Chris@0: $this->namespace = $namespace; Chris@0: $this->element = $element; Chris@0: } Chris@0: Chris@0: /** Chris@17: * @return string|null Chris@0: */ Chris@0: public function getNamespace() Chris@0: { Chris@0: return $this->namespace; Chris@0: } Chris@0: Chris@0: /** Chris@17: * @return string|null Chris@0: */ Chris@0: public function getElement() Chris@0: { Chris@0: return $this->element; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getSpecificity() Chris@0: { Chris@0: return new Specificity(0, 0, $this->element ? 1 : 0); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function __toString() Chris@0: { Chris@0: $element = $this->element ?: '*'; Chris@0: Chris@0: return sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element); Chris@0: } Chris@0: }