This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/CssSelector/Node/HashNode.php

76 lines
1.5 KiB
PHP
Raw Normal View History

2010-03-31 07:42:18 +01:00
<?php
/*
* This file is part of the Symfony package.
2010-03-31 07:42:18 +01:00
*
* (c) Fabien Potencier <fabien@symfony.com>
2010-03-31 07:42:18 +01:00
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\CssSelector\Node;
2010-03-31 07:42:18 +01:00
/**
* Represents a "<selector>#<id>" node.
2010-03-31 07:42:18 +01:00
*
* This component is a port of the Python cssselector library,
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
2010-03-31 07:42:18 +01:00
*
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
2010-03-31 07:42:18 +01:00
*/
class HashNode extends AbstractNode
2010-03-31 07:42:18 +01:00
{
/**
* @var NodeInterface
*/
private $selector;
2011-02-09 00:19:47 +00:00
/**
* @var string
2011-02-09 00:19:47 +00:00
*/
private $id;
/**
* @param NodeInterface $selector
* @param string $id
*/
public function __construct(NodeInterface $selector, $id)
{
$this->selector = $selector;
$this->id = $id;
}
2011-04-15 20:12:02 +01:00
/**
* @return NodeInterface
2011-02-09 00:19:47 +00:00
*/
public function getSelector()
{
return $this->selector;
}
2011-02-09 00:19:47 +00:00
/**
* @return string
2011-02-09 00:19:47 +00:00
*/
public function getId()
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getSpecificity()
{
return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0));
}
/**
* {@inheritdoc}
*/
public function __toString()
{
return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id);
}
2010-03-31 07:42:18 +01:00
}