|
| __construct ($output_precision=4, $internal_precision=10, $force_no_bcmath=false) |
|
| convert ($length, $to_unit) |
| Converts a length object of one unit into another unit.
|
|
| getSigFigs ($n) |
| Returns the number of significant figures in a string number.
|
|
|
const | DIGITAL = 3 |
|
const | ENGLISH = 1 |
|
const | METRIC = 2 |
|
|
static | $units |
| Units information array.
|
|
◆ convert()
HTMLPurifier_UnitConverter::convert |
( |
| $length, |
|
|
| $to_unit ) |
Converts a length object of one unit into another unit.
- Parameters
-
- Return values
-
- Note
- About precision: This conversion function pays very special attention to the incoming precision of values and attempts to maintain a number of significant figure. Results are fairly accurate up to nine digits. Some caveats:
- If a number is zero-padded as a result of this significant figure tracking, the zeroes will be eliminated.
- If a number contains less than four sigfigs ($outputPrecision) and this causes some decimals to be excluded, those decimals will be added on.
◆ getSigFigs()
HTMLPurifier_UnitConverter::getSigFigs |
( |
| $n | ) |
|
Returns the number of significant figures in a string number.
- Parameters
-
- Return values
-
◆ $internalPrecision
HTMLPurifier_UnitConverter::$internalPrecision |
|
protected |
Bcmath precision for internal calculations.
@type int
◆ $outputPrecision
HTMLPurifier_UnitConverter::$outputPrecision |
|
protected |
Minimum bcmath precision for output.
@type int
◆ $units
HTMLPurifier_UnitConverter::$units |
|
staticprotected |
Initial value:= array(
self::ENGLISH => array(
'px' => 3,
'pt' => 4,
'pc' => 48,
'in' => 288,
self::METRIC => array('pt', '0.352777778', 'mm'),
),
self::METRIC => array(
'mm' => 1,
'cm' => 10,
self::ENGLISH => array('mm', '2.83464567', 'pt'),
),
)
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.)
The documentation for this class was generated from the following file:
- lib/htmlpurifier/HTMLPurifier/UnitConverter.php