Dimension + optional units.
More...
|
| __construct ($dimension, $numeratorUnits, array $denominatorUnits=[]) |
| Initialize number.
|
|
| __toString () |
| {}
|
|
| assertNoUnits ($varName=null) |
|
| assertSameUnitOrUnitless (Number $other) |
|
| assertUnit ($unit, $varName=null) |
|
| coerce (array $newNumeratorUnits, array $newDenominatorUnits) |
| Returns a copy of this number, converted to the units represented by $newNumeratorUnits and $newDenominatorUnits.
|
|
| dividedBy (Number $other) |
|
| equals (Number $other) |
|
| getDenominatorUnits () |
|
| getDimension () |
|
| getNumeratorUnits () |
|
| greaterThan (Number $other) |
|
| greaterThanOrEqual (Number $other) |
|
| hasUnit ($unit) |
| Checks whether the number has exactly this unit.
|
|
| hasUnits () |
| Returns true if the number has any units.
|
|
| isComparableTo (Number $other) |
|
| jsonSerialize () |
|
| lessThan (Number $other) |
|
| lessThanOrEqual (Number $other) |
|
| minus (Number $other) |
|
| modulo (Number $other) |
|
| offsetExists ($offset) |
|
| offsetGet ($offset) |
|
| offsetSet ($offset, $value) |
|
| offsetUnset ($offset) |
|
| output (Compiler $compiler=null) |
| Output number.
|
|
| plus (Number $other) |
|
| times (Number $other) |
|
| unaryMinus () |
|
| unitless () |
| Returns true if the number is unitless.
|
|
| unitStr () |
| Returns unit(s) as the product of numerator units divided by the product of denominator units.
|
|
| valueInRange ($min, $max, $name=null) |
|
| valueInRangeWithUnit ($min, $max, $name, $unit) |
|
|
int null | $sourceColumn |
|
int | $sourceIndex |
|
int null | $sourceLine |
|
string | $type |
|
const | PRECISION = 10 |
|
Dimension + optional units.
{
◆ __construct()
ScssPhp\ScssPhp\Node\Number::__construct |
( |
| $dimension, |
|
|
| $numeratorUnits, |
|
|
array | $denominatorUnits = [] ) |
Initialize number.
- Parameters
-
int | float | $dimension | |
string[] | string | $numeratorUnits | |
string[] | $denominatorUnits | |
@phpstan-param list<string>|string $numeratorUnits @phpstan-param list<string> $denominatorUnits
◆ assertNoUnits()
ScssPhp\ScssPhp\Node\Number::assertNoUnits |
( |
| $varName = null | ) |
|
◆ assertSameUnitOrUnitless()
ScssPhp\ScssPhp\Node\Number::assertSameUnitOrUnitless |
( |
Number | $other | ) |
|
◆ assertUnit()
ScssPhp\ScssPhp\Node\Number::assertUnit |
( |
| $unit, |
|
|
| $varName = null ) |
- Parameters
-
string | $unit | |
string | null | $varName | |
- Return values
-
◆ coerce()
ScssPhp\ScssPhp\Node\Number::coerce |
( |
array | $newNumeratorUnits, |
|
|
array | $newDenominatorUnits ) |
Returns a copy of this number, converted to the units represented by $newNumeratorUnits and $newDenominatorUnits.
This does not throw an error if this number is unitless and $newNumeratorUnits/$newDenominatorUnits are not empty, or vice versa. Instead, it treats all unitless numbers as convertible to and from all units without changing the value.
- Parameters
-
string[] | $newNumeratorUnits | |
string[] | $newDenominatorUnits | |
- Return values
-
@phpstan-param list<string> $newNumeratorUnits @phpstan-param list<string> $newDenominatorUnits
- Exceptions
-
SassScriptException | if this number's units are not compatible with $newNumeratorUnits and $newDenominatorUnits |
◆ dividedBy()
ScssPhp\ScssPhp\Node\Number::dividedBy |
( |
Number | $other | ) |
|
◆ equals()
ScssPhp\ScssPhp\Node\Number::equals |
( |
Number | $other | ) |
|
◆ getDenominatorUnits()
ScssPhp\ScssPhp\Node\Number::getDenominatorUnits |
( |
| ) |
|
◆ getDimension()
ScssPhp\ScssPhp\Node\Number::getDimension |
( |
| ) |
|
◆ getNumeratorUnits()
ScssPhp\ScssPhp\Node\Number::getNumeratorUnits |
( |
| ) |
|
◆ greaterThan()
ScssPhp\ScssPhp\Node\Number::greaterThan |
( |
Number | $other | ) |
|
◆ greaterThanOrEqual()
ScssPhp\ScssPhp\Node\Number::greaterThanOrEqual |
( |
Number | $other | ) |
|
◆ hasUnit()
ScssPhp\ScssPhp\Node\Number::hasUnit |
( |
| $unit | ) |
|
Checks whether the number has exactly this unit.
- Parameters
-
- Return values
-
◆ hasUnits()
ScssPhp\ScssPhp\Node\Number::hasUnits |
( |
| ) |
|
Returns true if the number has any units.
- Return values
-
◆ isComparableTo()
ScssPhp\ScssPhp\Node\Number::isComparableTo |
( |
Number | $other | ) |
|
◆ jsonSerialize()
ScssPhp\ScssPhp\Node\Number::jsonSerialize |
( |
| ) |
|
◆ lessThan()
ScssPhp\ScssPhp\Node\Number::lessThan |
( |
Number | $other | ) |
|
◆ lessThanOrEqual()
ScssPhp\ScssPhp\Node\Number::lessThanOrEqual |
( |
Number | $other | ) |
|
◆ minus()
ScssPhp\ScssPhp\Node\Number::minus |
( |
Number | $other | ) |
|
◆ modulo()
ScssPhp\ScssPhp\Node\Number::modulo |
( |
Number | $other | ) |
|
◆ offsetExists()
ScssPhp\ScssPhp\Node\Number::offsetExists |
( |
| $offset | ) |
|
◆ offsetGet()
ScssPhp\ScssPhp\Node\Number::offsetGet |
( |
| $offset | ) |
|
◆ offsetSet()
ScssPhp\ScssPhp\Node\Number::offsetSet |
( |
| $offset, |
|
|
| $value ) |
◆ offsetUnset()
ScssPhp\ScssPhp\Node\Number::offsetUnset |
( |
| $offset | ) |
|
◆ output()
ScssPhp\ScssPhp\Node\Number::output |
( |
Compiler | $compiler = null | ) |
|
Output number.
- Parameters
-
- Return values
-
◆ plus()
ScssPhp\ScssPhp\Node\Number::plus |
( |
Number | $other | ) |
|
◆ times()
ScssPhp\ScssPhp\Node\Number::times |
( |
Number | $other | ) |
|
◆ unaryMinus()
ScssPhp\ScssPhp\Node\Number::unaryMinus |
( |
| ) |
|
◆ unitless()
ScssPhp\ScssPhp\Node\Number::unitless |
( |
| ) |
|
Returns true if the number is unitless.
- Return values
-
◆ unitStr()
ScssPhp\ScssPhp\Node\Number::unitStr |
( |
| ) |
|
Returns unit(s) as the product of numerator units divided by the product of denominator units.
- Return values
-
◆ valueInRange()
ScssPhp\ScssPhp\Node\Number::valueInRange |
( |
| $min, |
|
|
| $max, |
|
|
| $name = null ) |
- Parameters
-
float | int | $min | |
float | int | $max | |
string | null | $name | |
- Return values
-
- Exceptions
-
◆ valueInRangeWithUnit()
ScssPhp\ScssPhp\Node\Number::valueInRangeWithUnit |
( |
| $min, |
|
|
| $max, |
|
|
| $name, |
|
|
| $unit ) |
- Parameters
-
float | int | $min | |
float | int | $max | |
string | $name | |
string | $unit | |
- Return values
-
- Exceptions
-
◆ $precision
int ScssPhp\ScssPhp\Node\Number::$precision = self::PRECISION |
|
static |
- Deprecated
- use {Number\PRECISION} instead to read the precision. Configuring it is not supported anymore.
◆ $unitTable
array ScssPhp\ScssPhp\Node\Number::$unitTable |
|
staticprotected |
Initial value:= [
'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.28318530717958647692528676,
'turn' => 1,
],
's' => [
's' => 1,
'ms' => 1000,
],
'Hz' => [
'Hz' => 1,
'kHz' => 0.001,
],
'dpi' => [
'dpi' => 1,
'dpcm' => 1 / 2.54,
'dppx' => 1 / 96,
],
]
- See also
- http://www.w3.org/TR/2012/WD-css3-values-20120308/
@phpstan-var array<string, array<string, float|int>>
The documentation for this class was generated from the following file:
- lib/scssphp/Node/Number.php