Skip to content

Commit

Permalink
[CLEANUP] Avoid Hungarian notation for selector (#986)
Browse files Browse the repository at this point in the history
Part of #756
  • Loading branch information
oliverklee authored Feb 25, 2025
1 parent 6ff4aa5 commit ce26af6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/Property/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,30 @@ class Selector
/**
* @var string
*/
private $sSelector;
private $selector;

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

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

/**
* @param string $sSelector
* @param string $selector
* @param bool $bCalculateSpecificity
*/
public function __construct($sSelector, $bCalculateSpecificity = false)
public function __construct($selector, $bCalculateSpecificity = false)
{
$this->setSelector($sSelector);
$this->setSelector($selector);
if ($bCalculateSpecificity) {
$this->getSpecificity();
}
Expand All @@ -101,15 +101,15 @@ public function __construct($sSelector, $bCalculateSpecificity = false)
*/
public function getSelector()
{
return $this->sSelector;
return $this->selector;
}

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

Expand All @@ -127,9 +127,9 @@ public function getSpecificity()
$a = 0;
/// @todo should exclude \# as well as "#"
$aMatches = null;
$b = \substr_count($this->sSelector, '#');
$c = \preg_match_all(self::NON_ID_ATTRIBUTES_AND_PSEUDO_CLASSES_RX, $this->sSelector, $aMatches);
$d = \preg_match_all(self::ELEMENTS_AND_PSEUDO_ELEMENTS_RX, $this->sSelector, $aMatches);
$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;
}
return $this->iSpecificity;
Expand Down

0 comments on commit ce26af6

Please sign in to comment.