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

48 lines
1.1 KiB
PHP
Raw Normal View History

2010-03-31 07:42:18 +01:00
<?php
namespace Symfony\Component\CssSelector\Node;
2010-03-31 07:42:18 +01:00
use Symfony\Component\CssSelector\XPathExpr;
2010-03-31 07:42:18 +01:00
/*
* This file is part of the Symfony package.
2010-03-31 07:42:18 +01:00
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* HashNode represents a "selector#id" node.
*
* This component is a port of the Python lxml library,
* which is copyright Infrae and distributed under the BSD license.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class HashNode implements NodeInterface
{
protected $selector;
protected $id;
public function __construct($selector, $id)
{
$this->selector = $selector;
$this->id = $id;
}
public function __toString()
{
return sprintf('%s[%s#%s]', __CLASS__, $this->selector, $this->id);
}
public function toXpath()
{
$path = $this->selector->toXpath();
$path->addCondition(sprintf('@id = %s', XPathExpr::xpathLiteral($this->id)));
return $path;
}
2010-03-31 07:42:18 +01:00
}