XPathExpr.php in Zircon Profile 8
File
vendor/symfony/css-selector/XPath/XPathExpr.php
View source
<?php
namespace Symfony\Component\CssSelector\XPath;
class XPathExpr {
private $path;
private $element;
private $condition;
public function __construct($path = '', $element = '*', $condition = '', $starPrefix = false) {
$this->path = $path;
$this->element = $element;
$this->condition = $condition;
if ($starPrefix) {
$this
->addStarPrefix();
}
}
public function getElement() {
return $this->element;
}
public function addCondition($condition) {
$this->condition = $this->condition ? sprintf('%s and (%s)', $this->condition, $condition) : $condition;
return $this;
}
public function getCondition() {
return $this->condition;
}
public function addNameTest() {
if ('*' !== $this->element) {
$this
->addCondition('name() = ' . Translator::getXpathLiteral($this->element));
$this->element = '*';
}
return $this;
}
public function addStarPrefix() {
$this->path .= '*/';
return $this;
}
public function join($combiner, XPathExpr $expr) {
$path = $this
->__toString() . $combiner;
if ('*/' !== $expr->path) {
$path .= $expr->path;
}
$this->path = $path;
$this->element = $expr->element;
$this->condition = $expr->condition;
return $this;
}
public function __toString() {
$path = $this->path . $this->element;
$condition = null === $this->condition || '' === $this->condition ? '' : '[' . $this->condition . ']';
return $path . $condition;
}
}
Classes
Name |
Description |
XPathExpr |
XPath expression translator interface. |