HTMLPurifier_Length
in package
Represents a measurable length, with a string numeric magnitude and a unit. This object is immutable.
Table of Contents
Properties
- $allowedUnits : mixed
- Array Lookup array of units recognized by CSS 3
- $isValid : mixed
- Whether or not this length is valid. Null if not calculated yet.
- $n : mixed
- String numeric magnitude.
- $unit : mixed
- String unit. False is permitted if $n = 0.
Methods
- __construct() : mixed
- compareTo() : int
- Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal.
- getN() : string
- Retrieves string numeric magnitude.
- getUnit() : string
- Retrieves string unit.
- isValid() : bool
- Returns true if this length unit is valid.
- make() : HTMLPurifier_Length
- toString() : string
- Returns string representation of number.
- validate() : bool
- Validates the number and unit.
Properties
$allowedUnits
Array Lookup array of units recognized by CSS 3
protected
static mixed
$allowedUnits
= array('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)
Tags
$isValid
Whether or not this length is valid. Null if not calculated yet.
protected
mixed
$isValid
Tags
$n
String numeric magnitude.
protected
mixed
$n
Tags
$unit
String unit. False is permitted if $n = 0.
protected
mixed
$unit
Tags
Methods
__construct()
public
__construct([string $n = '0' ][, bool|string $u = false ]) : mixed
Parameters
- $n : string = '0'
-
Magnitude
- $u : bool|string = false
-
Unit
compareTo()
Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal.
public
compareTo(HTMLPurifier_Length $l) : int
Parameters
- $l : HTMLPurifier_Length
Tags
Return values
intgetN()
Retrieves string numeric magnitude.
public
getN() : string
Return values
stringgetUnit()
Retrieves string unit.
public
getUnit() : string
Return values
stringisValid()
Returns true if this length unit is valid.
public
isValid() : bool
Return values
boolmake()
public
static make(string $s) : HTMLPurifier_Length
Parameters
- $s : string
-
Unit string, like '2em' or '3.4in'
Tags
Return values
HTMLPurifier_LengthtoString()
Returns string representation of number.
public
toString() : string
Return values
stringvalidate()
Validates the number and unit.
protected
validate() : bool