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 combined 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 CombinedSelectorNode extends AbstractNode Chris@0: { Chris@0: private $selector; Chris@0: private $combinator; Chris@0: private $subSelector; Chris@0: Chris@0: /** Chris@0: * @param NodeInterface $selector Chris@0: * @param string $combinator Chris@0: * @param NodeInterface $subSelector Chris@0: */ Chris@0: public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector) Chris@0: { Chris@0: $this->selector = $selector; Chris@0: $this->combinator = $combinator; Chris@0: $this->subSelector = $subSelector; 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 getCombinator() Chris@0: { Chris@0: return $this->combinator; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return NodeInterface Chris@0: */ Chris@0: public function getSubSelector() Chris@0: { Chris@0: return $this->subSelector; 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($this->subSelector->getSpecificity()); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function __toString() Chris@0: { Chris@0: $combinator = ' ' === $this->combinator ? '' : $this->combinator; Chris@0: Chris@0: return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector); Chris@0: } Chris@0: }