Class HTMLPurifier_Length

InheritanceHTMLPurifier_Length

Represents a measurable length, with a string numeric magnitude and a unit. This object is immutable.

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined 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

Hide inherited methods

MethodDescriptionDefined 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

Hide inherited methods

MethodDescriptionDefined By
validate() Validates the number and unit. HTMLPurifier_Length

Property Details

$allowedUnits protected static property
protected static $allowedUnits = ['em' => true'ex' => true'px' => true'in' => true'cm' => true'mm' => true'pt' => true'pc' => true]
$isValid protected property
protected $isValid null
$n protected property
protected $n null
$unit protected property
protected $unit null

Method Details

__construct() public method

public void __construct ( $n '0', $u false )
$n string

Magnitude

$u bool|string

Unit

compareTo() public method

Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal.

public int compareTo ( $l )
$l HTMLPurifier_Length
getN() public method

Retrieves string numeric magnitude.

public string getN ( )
getUnit() public method

Retrieves string unit.

public string getUnit ( )
isValid() public method

Returns true if this length unit is valid.

public bool isValid ( )
make() public static method

public static HTMLPurifier_Length make ( $s )
$s string

Unit string, like '2em' or '3.4in'

toString() public method

Returns string representation of number.

public string toString ( )
validate() protected method

Validates the number and unit.

protected bool validate ( )