Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/Property/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,30 @@ class Selector
)$
/ux';

/**
* @var string
*/
private $sSelector;

/**
* @var int|null
*/
private $iSpecificity;

/**
* @param string $sSelector
*
* @return bool
*/
public static function isValid($sSelector)
{
return preg_match(static::SELECTOR_VALIDATION_RX, $sSelector);
}

/**
* @param string $sSelector
* @param bool $bCalculateSpecificity
*/
public function __construct($sSelector, $bCalculateSpecificity = false)
{
$this->setSelector($sSelector);
Expand All @@ -77,22 +92,36 @@ public function __construct($sSelector, $bCalculateSpecificity = false)
}
}

/**
* @return string
*/
public function getSelector()
{
return $this->sSelector;
}

/**
* @param string $sSelector
*
* @return void
*/
public function setSelector($sSelector)
{
$this->sSelector = trim($sSelector);
$this->iSpecificity = null;
}

/**
* @return string
*/
public function __toString()
{
return $this->getSelector();
}

/**
* @return int
*/
public function getSpecificity()
{
if ($this->iSpecificity === null) {
Expand Down