Represents a measurable length, with a string numeric magnitude and a unit. This object is immutable.
Methods | ||||||
---|---|---|---|---|---|---|
public
|
__construct(string $n = '0', bool|string $u = false)
Parameters
|
# | ||||
public
static
|
make(string $s): HTMLPurifier_Length
Parameters
|
# | ||||
protected
|
validate(): bool
Validates the number and unit.
Validates the number and unit. |
# | ||||
public
|
toString(): string
Returns string representation of number.
Returns string representation of number. |
# | ||||
public
|
getN(): string
Retrieves string numeric magnitude.
Retrieves string numeric magnitude. |
# | ||||
public
|
getUnit(): string
Retrieves string unit.
Retrieves string unit. |
# | ||||
public
|
isValid(): bool
Returns true if this length unit is valid.
Returns true if this length unit is valid. |
# | ||||
public
|
compareTo(HTMLPurifier_Length $l): int
Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal.
Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal. |
# |
Properties | |||
---|---|---|---|
protected
|
|
$n
String numeric magnitude.
String numeric magnitude. |
# |
protected
|
|
$unit
String unit. False is permitted if $n = 0.
String unit. False is permitted if $n = 0. |
# |
protected
|
|
$isValid
Whether or not this length is valid. Null if not calculated yet.
Whether or not this length is valid. Null if not calculated yet. |
# |
protected
static
|
|
$allowedUnits = [
'em' => true,
'ex' => true,
'px' => true,
'in' => true,
'cm' => true,
'mm' => true,
'pt' => true,
'pc' => true,
'ch' => true,
'rem' => true,
'vw' => true,
'vh' => true,
'vmin' => true,
'vmax' => true,
]
Array Lookup array of units recognized by CSS 3
Array Lookup array of units recognized by CSS 3 |
# |