Number
extends Node
in package
implements
ArrayAccess
Dimension + optional units
}
Tags
Interfaces, Classes and Traits
- ArrayAccess
Table of Contents
- $dimension : int|float
- $precision : int
- $sourceColumn : int
- $sourceIndex : int
- $sourceLine : int
- $type : string
- $units : array<string|int, mixed>
- $unitTable : array<string|int, mixed>
- __construct() : mixed
- Initialize number
- __toString() : mixed
- {@inheritdoc}
- coerce() : Number
- Coerce number to target units
- normalize() : Number
- Normalize number
- offsetExists() : mixed
- {@inheritdoc}
- offsetGet() : mixed
- {@inheritdoc}
- offsetSet() : mixed
- {@inheritdoc}
- offsetUnset() : mixed
- {@inheritdoc}
- output() : string
- Output number
- unitless() : bool
- Returns true if the number is unitless
- unitStr() : string
- Returns unit(s) as the product of numerator units divided by the product of denominator units
- normalizeUnits() : mixed
- Normalize units
Properties
$dimension
public
int|float
$dimension
$precision
public
static int
$precision
= 10
$sourceColumn
public
int
$sourceColumn
$sourceIndex
public
int
$sourceIndex
$sourceLine
public
int
$sourceLine
$type
public
string
$type
$units
public
array<string|int, mixed>
$units
$unitTable
protected
static array<string|int, mixed>
$unitTable
= ['in' => ['in' => 1, 'pc' => 6, 'pt' => 72, 'px' => 96, 'cm' => 2.54, 'mm' => 25.4, 'q' => 101.6], 'turn' => [
'deg' => 360,
'grad' => 400,
'rad' => 6.283185307179586,
// 2 * M_PI
'turn' => 1,
], 's' => ['s' => 1, 'ms' => 1000], 'Hz' => ['Hz' => 1, 'kHz' => 0.001], 'dpi' => ['dpi' => 1, 'dpcm' => 2.54, 'dppx' => 96]]
Tags
Methods
__construct()
Initialize number
public
__construct(mixed $dimension, mixed $initialUnit) : mixed
Parameters
- $dimension : mixed
- $initialUnit : mixed
Return values
mixed —__toString()
{@inheritdoc}
public
__toString() : mixed
Return values
mixed —coerce()
Coerce number to target units
public
coerce(array<string|int, mixed> $units) : Number
Parameters
- $units : array<string|int, mixed>
Return values
Number —normalize()
Normalize number
public
normalize() : Number
Return values
Number —offsetExists()
{@inheritdoc}
public
offsetExists(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —offsetGet()
{@inheritdoc}
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —offsetSet()
{@inheritdoc}
public
offsetSet(mixed $offset, mixed $value) : mixed
Parameters
- $offset : mixed
- $value : mixed
Return values
mixed —offsetUnset()
{@inheritdoc}
public
offsetUnset(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —output()
Output number
public
output([Compiler $compiler = null ]) : string
Parameters
- $compiler : Compiler = null
Return values
string —unitless()
Returns true if the number is unitless
public
unitless() : bool
Return values
bool —unitStr()
Returns unit(s) as the product of numerator units divided by the product of denominator units
public
unitStr() : string
Return values
string —normalizeUnits()
Normalize units
private
normalizeUnits(int|float &$dimension, array<string|int, mixed> &$units[, string $baseUnit = 'in' ]) : mixed
Parameters
- $dimension : int|float
- $units : array<string|int, mixed>
- $baseUnit : string = 'in'