Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
HTMLPurifier_Length Class Reference

Public Member Functions

 __construct ($n='0', $u=false)
 
 compareTo ($l)
 Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal.
 
 getN ()
 Retrieves string numeric magnitude.
 
 getUnit ()
 Retrieves string unit.
 
 isValid ()
 Returns true if this length unit is valid.
 
 toString ()
 Returns string representation of number.
 

Static Public Member Functions

static make ($s)
 

Protected Member Functions

 validate ()
 Validates the number and unit.
 

Protected Attributes

 $isValid
 Whether or not this length is valid.
 
 $n
 String numeric magnitude.
 
 $unit
 String unit.
 

Static Protected Attributes

static $allowedUnits
 Array Lookup array of units recognized by CSS 3 @type array.
 

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_Length::__construct ( $n = '0',
$u = false )
Parameters
string$nMagnitude
bool | string$uUnit

Member Function Documentation

◆ compareTo()

HTMLPurifier_Length::compareTo ( $l)

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

Parameters
HTMLPurifier_Length$l
Return values
int
Warning
If both values are too large or small, this calculation will not work properly

◆ getN()

HTMLPurifier_Length::getN ( )

Retrieves string numeric magnitude.

Return values
string

◆ getUnit()

HTMLPurifier_Length::getUnit ( )

Retrieves string unit.

Return values
string

◆ isValid()

HTMLPurifier_Length::isValid ( )

Returns true if this length unit is valid.

Return values
bool

◆ make()

static HTMLPurifier_Length::make ( $s)
static
Parameters
string$sUnit string, like '2em' or '3.4in'
Return values
HTMLPurifier_Length
Warning
Does not perform validation.

◆ toString()

HTMLPurifier_Length::toString ( )

Returns string representation of number.

Return values
string

◆ validate()

HTMLPurifier_Length::validate ( )
protected

Validates the number and unit.

Return values
bool

Member Data Documentation

◆ $allowedUnits

HTMLPurifier_Length::$allowedUnits
staticprotected
Initial value:
= 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
)

Array Lookup array of units recognized by CSS 3 @type array.

◆ $isValid

HTMLPurifier_Length::$isValid
protected

Whether or not this length is valid.

Null if not calculated yet. @type bool

◆ $n

HTMLPurifier_Length::$n
protected

String numeric magnitude.

@type string

◆ $unit

HTMLPurifier_Length::$unit
protected

String unit.

False is permitted if $n = 0. @type string|bool


The documentation for this class was generated from the following file: