Table of contents
Namespace: Com\Tecnick\Pdf\CSS
File: Specificity.php line 37
CSS 2.1 specificity (a,b,c) tuple calculator and comparator:
- a = number of ID selectors
- b = number of class selectors, attribute selectors, and pseudo-classes
- c = number of type selectors and pseudo-elements
Tags
- since: 2002-08-03
- category: Library
- author: Nicola Asuni info@tecnick.com
- copyright: 2002-2026 Nicola Asuni - Tecnick.com LTD
- license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
- link: https://github.com/tecnickcom/tc-lib-pdf
Properties
$classCount
File: Specificity.php line 47
public int $classCount = 0
$idCount
File: Specificity.php line 42
public int $idCount = 0
$typeCount
File: Specificity.php line 52
public int $typeCount = 0
Methods
__construct()
File: Specificity.php line 61
public __construct([int $idCount = 0 ][, int $classCount = 0 ][, int $typeCount = 0 ]) : mixed
Parameters
- $idCount : int = 0: Number of ID selectors
- $classCount : int = 0: Number of class/attribute/pseudo-class selectors
- $typeCount : int = 0: Number of type selectors and pseudo-elements
compareTo()
File: Specificity.php line 107
public compareTo(self $other) : int
Parameters
- $other : self: The specificity to compare against
Return values
int —
-1 if this < other, 0 if equal, 1 if this > other
equals()
File: Specificity.php line 149
public equals(self $other) : bool
Parameters
- $other : self
Return values
bool
fromLegacyString()
File: Specificity.php line 199
public static fromLegacyString(string $legacyStr) : self
Parameters
- $legacyStr : string: Legacy format string (e.g., “0123”)
Return values
self
fromSelector()
File: Specificity.php line 74
public static fromSelector(string $selector) : self
Parameters
- $selector : string: CSS selector string
Return values
self
isGreaterThan()
File: Specificity.php line 138
public isGreaterThan(self $other) : bool
Parameters
- $other : self
Return values
bool
isLessThan()
File: Specificity.php line 127
public isLessThan(self $other) : bool
Parameters
- $other : self
Return values
bool
toLegacyString()
File: Specificity.php line 188
public toLegacyString([int $inlineStyle = 0 ]) : string
Format: inline-style flag followed by the id, class and type counts (e.g. “0123” = inline-style 0, 1 id, 2 classes, 3 types). Internal comparisons use the numeric tuple instead.
Parameters
- $inlineStyle : int = 0: 0 for rule, 1 for inline
Return values
string
toSortKey()
File: Specificity.php line 163
public toSortKey([int $sourceOrder = 0 ]) : string
Format: “{a:04d}{b:04d}{c:04d}_{index:06d}” This allows string-based sorting to maintain specificity precedence
Parameters
- $sourceOrder : int = 0: Source order index for tie-breaking
Return values
string —
Sortable key
toString()
File: Specificity.php line 173
public toString() : string
Return values
string