Commaaa2
This commit is contained in:
22
vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
22
vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
@@ -23,16 +23,12 @@ namespace Symfony\Component\CssSelector\XPath;
|
||||
*/
|
||||
class XPathExpr
|
||||
{
|
||||
private string $path;
|
||||
private string $element;
|
||||
private string $condition;
|
||||
|
||||
public function __construct(string $path = '', string $element = '*', string $condition = '', bool $starPrefix = false)
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->element = $element;
|
||||
$this->condition = $condition;
|
||||
|
||||
public function __construct(
|
||||
private string $path = '',
|
||||
private string $element = '*',
|
||||
private string $condition = '',
|
||||
bool $starPrefix = false,
|
||||
) {
|
||||
if ($starPrefix) {
|
||||
$this->addStarPrefix();
|
||||
}
|
||||
@@ -46,9 +42,9 @@ class XPathExpr
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addCondition(string $condition): static
|
||||
public function addCondition(string $condition, string $operator = 'and'): static
|
||||
{
|
||||
$this->condition = $this->condition ? sprintf('(%s) and (%s)', $this->condition, $condition) : $condition;
|
||||
$this->condition = $this->condition ? sprintf('(%s) %s (%s)', $this->condition, $operator, $condition) : $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -104,7 +100,7 @@ class XPathExpr
|
||||
public function __toString(): string
|
||||
{
|
||||
$path = $this->path.$this->element;
|
||||
$condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']';
|
||||
$condition = '' === $this->condition ? '' : '['.$this->condition.']';
|
||||
|
||||
return $path.$condition;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user