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
16 changes: 8 additions & 8 deletions src/Property/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Selector
/**
* @var int|null
*/
private $iSpecificity;
private $specificity;

/**
* @param string $selector
Expand All @@ -86,12 +86,12 @@ public static function isValid($selector)

/**
* @param string $selector
* @param bool $bCalculateSpecificity
* @param bool $calculateSpecificity
*/
public function __construct($selector, $bCalculateSpecificity = false)
public function __construct($selector, $calculateSpecificity = false)
{
$this->setSelector($selector);
if ($bCalculateSpecificity) {
if ($calculateSpecificity) {
$this->getSpecificity();
}
}
Expand All @@ -110,7 +110,7 @@ public function getSelector()
public function setSelector($selector): void
{
$this->selector = \trim($selector);
$this->iSpecificity = null;
$this->specificity = null;
}

public function __toString(): string
Expand All @@ -123,15 +123,15 @@ public function __toString(): string
*/
public function getSpecificity()
{
if ($this->iSpecificity === null) {
if ($this->specificity === null) {
$a = 0;
/// @todo should exclude \# as well as "#"
$aMatches = null;
$b = \substr_count($this->selector, '#');
$c = \preg_match_all(self::NON_ID_ATTRIBUTES_AND_PSEUDO_CLASSES_RX, $this->selector, $aMatches);
$d = \preg_match_all(self::ELEMENTS_AND_PSEUDO_ELEMENTS_RX, $this->selector, $aMatches);
$this->iSpecificity = ($a * 1000) + ($b * 100) + ($c * 10) + $d;
$this->specificity = ($a * 1000) + ($b * 100) + ($c * 10) + $d;
}
return $this->iSpecificity;
return $this->specificity;
}
}