\HTMLPurifier_UnitConverter
Class for converting between different unit-lengths as specified by CSS.
Synopsis
class HTMLPurifier_UnitConverter
{
- // constants
- const ENGLISH = 1;
- const METRIC = 2;
- const DIGITAL = 3;
- // members
- protected static array $units = ;
- protected $outputPrecision;
- protected $internalPrecision;
- private $bcmath;
- // methods
- public void __construct()
- public void convert()
- public int getSigFigs()
- private void add()
- private void mul()
- private void div()
- private void round()
- private void scale()
Constants
Name | Value |
---|---|
ENGLISH | 1 |
METRIC | 2 |
DIGITAL | 3 |
Members
private
-
$bcmath
Whether or not BCMath is available
protected
-
$internalPrecision
Bcmath precision for internal calculations. -
$outputPrecision
Minimum bcmath precision for output. -
$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.)
Methods
private
- add() — Adds two numbers, using arbitrary precision when available.
- div() — Divides two numbers, using arbitrary precision when available.
- mul() — Multiples two numbers, using arbitrary precision when available.
- round() — Rounds a number according to the number of sigfigs it should have, using arbitrary precision when available.
- scale() — Scales a float to $scale digits right of decimal point, like BCMath.
public
- __construct()
- convert() — Converts a length object of one unit into another unit.
- getSigFigs() — Returns the number of significant figures in a string number.