Skip to content

HTMLPurifier_Length

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

  • Full name: \HTMLPurifier_Length

Properties

n

String numeric magnitude.

protected $n

unit

String unit. False is permitted if $n = 0.

protected $unit

isValid

Whether or not this length is valid. Null if not calculated yet.

protected $isValid

allowedUnits

Array Lookup array of units recognized by CSS 3

protected static $allowedUnits
  • This property is static.

Methods

__construct

public __construct(string $n = '0', bool|string $u = false): mixed

Parameters:

Parameter Type Description
$n string Magnitude
$u bool|string Unit

make

public static make(string $s): \HTMLPurifier_Length
  • This method is static.

Parameters:

Parameter Type Description
$s string Unit string, like '2em' or '3.4in'

validate

Validates the number and unit.

protected validate(): bool

toString

Returns string representation of number.

public toString(): string

getN

Retrieves string numeric magnitude.

public getN(): string

getUnit

Retrieves string unit.

public getUnit(): string

isValid

Returns true if this length unit is valid.

public isValid(): bool

compareTo

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

public compareTo(\HTMLPurifier_Length $l): int

Parameters:

Parameter Type Description
$l \HTMLPurifier_Length


Automatically generated on 2025-03-18