HTMLPurifier_UnitConverter
Class for converting between different unit-lengths as specified by CSS.
- Full name:
\HTMLPurifier_UnitConverter
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
ENGLISH |
public | 1 | |
METRIC |
public | 2 | |
DIGITAL |
public | 3 |
Properties
units
Units information array. Units are grouped into measuring systems (English, Metric), and are assigned an integer representing the conversion factor between that unit and the smallest unit in the system. Numeric indexes are actually magical constants that encode conversion data from one system to the next, with a O(n^2) constraint on memory (this is generally not a problem, since the number of measuring systems is small.)
- This property is static.
outputPrecision
Minimum bcmath precision for output.
internalPrecision
Bcmath precision for internal calculations.
bcmath
Whether or not BCMath is available.
Methods
__construct
public __construct(mixed $output_precision = 4, mixed $internal_precision = 10, mixed $force_no_bcmath = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$output_precision |
mixed | |
$internal_precision |
mixed | |
$force_no_bcmath |
mixed |
convert
Converts a length object of one unit into another unit.
Parameters:
Parameter | Type | Description |
---|---|---|
$length |
\HTMLPurifier_Length | Instance of HTMLPurifier_Length to convert. You must validate() it before passing it here! |
$to_unit |
string | Unit to convert to. |
getSigFigs
Returns the number of significant figures in a string number.
Parameters:
Parameter | Type | Description |
---|---|---|
$n |
string | Decimal number |
Return Value:
number of sigfigs
add
Adds two numbers, using arbitrary precision when available.
Parameters:
Parameter | Type | Description |
---|---|---|
$s1 |
string | |
$s2 |
string | |
$scale |
int |
mul
Multiples two numbers, using arbitrary precision when available.
Parameters:
Parameter | Type | Description |
---|---|---|
$s1 |
string | |
$s2 |
string | |
$scale |
int |
div
Divides two numbers, using arbitrary precision when available.
Parameters:
Parameter | Type | Description |
---|---|---|
$s1 |
string | |
$s2 |
string | |
$scale |
int |
round
Rounds a number according to the number of sigfigs it should have, using arbitrary precision when available.
Parameters:
Parameter | Type | Description |
---|---|---|
$n |
float | |
$sigfigs |
int |
scale
Scales a float to $scale digits right of decimal point, like BCMath.
Parameters:
Parameter | Type | Description |
---|---|---|
$r |
float | |
$scale |
int |
Automatically generated on 2025-03-18