Class HTMLPurifier_Length
Inheritance | HTMLPurifier_Length |
---|
Represents a measurable length, with a string numeric magnitude and a unit. This object is immutable.
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$allowedUnits | Array Lookup array of units recognized by CSS 2.1 | HTMLPurifier_Length | |
$isValid | Whether or not this length is valid. Null if not calculated yet. | HTMLPurifier_Length | |
$n | String numeric magnitude. | HTMLPurifier_Length | |
$unit | String unit. False is permitted if $n = 0. | HTMLPurifier_Length |
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | HTMLPurifier_Length | |
compareTo() | Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal. | HTMLPurifier_Length |
getN() | Retrieves string numeric magnitude. | HTMLPurifier_Length |
getUnit() | Retrieves string unit. | HTMLPurifier_Length |
isValid() | Returns true if this length unit is valid. | HTMLPurifier_Length |
make() | HTMLPurifier_Length | |
toString() | Returns string representation of number. | HTMLPurifier_Length |
Protected Methods
Method | Description | Defined By |
---|---|---|
validate() | Validates the number and unit. | HTMLPurifier_Length |
Property Details
protected static $allowedUnits = ['em' => true, 'ex' => true, 'px' => true, 'in' => true, 'cm' => true, 'mm' => true, 'pt' => true, 'pc' => true]
Method Details
public void __construct ( $n = '0', $u = false ) | ||
$n | string | Magnitude |
$u | bool|string | Unit |
Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal.
public int compareTo ( $l ) | ||
$l | HTMLPurifier_Length |
Retrieves string numeric magnitude.
public string getN ( ) |
Retrieves string unit.
public string getUnit ( ) |
Returns true if this length unit is valid.
public bool isValid ( ) |
public static HTMLPurifier_Length make ( $s ) | ||
$s | string | Unit string, like '2em' or '3.4in' |
Returns string representation of number.
public string toString ( ) |
Validates the number and unit.
protected bool validate ( ) |