Class HTMLPurifier_UnitConverter
Inheritance | HTMLPurifier_UnitConverter |
---|
Class for converting between different unit-lengths as specified by CSS.
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$internalPrecision | Bcmath precision for internal calculations. | HTMLPurifier_UnitConverter | |
$outputPrecision | Minimum bcmath precision for output. | HTMLPurifier_UnitConverter | |
$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.) | HTMLPurifier_UnitConverter |
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | HTMLPurifier_UnitConverter | |
convert() | Converts a length object of one unit into another unit. | HTMLPurifier_UnitConverter |
getSigFigs() | Returns the number of significant figures in a string number. | HTMLPurifier_UnitConverter |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
DIGITAL | 3 | HTMLPurifier_UnitConverter | |
ENGLISH | 1 | HTMLPurifier_UnitConverter | |
METRIC | 2 | HTMLPurifier_UnitConverter |
Property Details
protected static $units = [self::ENGLISH => ['px' => 3, 'pt' => 4, 'pc' => 48, 'in' => 288, self::METRIC => ['pt', '0.352777778', 'mm']], self::METRIC => ['mm' => 1, 'cm' => 10, self::ENGLISH => ['mm', '2.83464567', 'pt']]]
Method Details
public void __construct ( $output_precision = 4, $internal_precision = 10, $force_no_bcmath = false ) | ||
$output_precision | ||
$internal_precision | ||
$force_no_bcmath |
Converts a length object of one unit into another unit.
public HTMLPurifier_Length|bool convert ( $length, $to_unit ) | ||
$length | HTMLPurifier_Length | Instance of HTMLPurifier_Length to convert. You must validate()
|
$to_unit | string | Unit to convert to. |
Returns the number of significant figures in a string number.
public int getSigFigs ( $n ) | ||
$n | string | Decimal number |
return | int | Number of sigfigs |
---|