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 "<namespace>|<element>" 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 ElementNode extends AbstractNode
30 * @param string|null $namespace
31 * @param string|null $element
33 public function __construct($namespace = null, $element = null)
35 $this->namespace = $namespace;
36 $this->element = $element;
42 public function getNamespace()
44 return $this->namespace;
50 public function getElement()
52 return $this->element;
58 public function getSpecificity()
60 return new Specificity(0, 0, $this->element ? 1 : 0);
66 public function __toString()
68 $element = $this->element ?: '*';
70 return sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element);