Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

SCSSPHP

Copyright: 2012-2020 Leaf Corcoran
License: http://opensource.org/licenses/MIT MIT
File Size: 737 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Number:: (33 methods):
  __construct()
  getDimension()
  getNumeratorUnits()
  getDenominatorUnits()
  offsetExists()
  offsetGet()
  offsetSet()
  offsetUnset()
  unitless()
  hasUnit()
  unitStr()
  assertNoUnits()
  assertSameUnitOrUnitless()
  isComparableTo()
  lessThan()
  lessThanOrEqual()
  greaterThan()
  greaterThanOrEqual()
  plus()
  minus()
  unaryMinus()
  modulo()
  times()
  dividedBy()
  equals()
  output()
  __toString()
  coerceNumber()
  coerceUnits()
  valueInUnits()
  multiplyUnits()
  getConversionFactor()
  getUnitString()


Class: Number  - X-Ref

Dimension + optional units

{@internal
This is a work-in-progress.

The \ArrayAccess interface is temporary until the migration is complete.
}}

__construct($dimension, $numeratorUnits, array $denominatorUnits = [])   X-Ref
Initialize number

param: integer|float   $dimension
param: string[]|string $numeratorUnits
param: string[]        $denominatorUnits

getDimension()   X-Ref

return: float|int

getNumeratorUnits()   X-Ref

return: string[]

getDenominatorUnits()   X-Ref

return: string[]

offsetExists($offset)   X-Ref
{@inheritdoc}


offsetGet($offset)   X-Ref
{@inheritdoc}


offsetSet($offset, $value)   X-Ref
{@inheritdoc}


offsetUnset($offset)   X-Ref
{@inheritdoc}


unitless()   X-Ref
Returns true if the number is unitless

return: boolean

hasUnit($unit)   X-Ref
Checks whether the number has exactly this unit

param: string $unit
return: bool

unitStr()   X-Ref
Returns unit(s) as the product of numerator units divided by the product of denominator units

return: string

assertNoUnits($varName = null)   X-Ref

param: string|null $varName
return: void

assertSameUnitOrUnitless(Number $other)   X-Ref

param: Number $other
return: void

isComparableTo(Number $other)   X-Ref

param: Number $other
return: bool

lessThan(Number $other)   X-Ref

param: Number $other
return: bool

lessThanOrEqual(Number $other)   X-Ref

param: Number $other
return: bool

greaterThan(Number $other)   X-Ref

param: Number $other
return: bool

greaterThanOrEqual(Number $other)   X-Ref

param: Number $other
return: bool

plus(Number $other)   X-Ref

param: Number $other
return: Number

minus(Number $other)   X-Ref

param: Number $other
return: Number

unaryMinus()   X-Ref

return: Number

modulo(Number $other)   X-Ref

param: Number $other
return: Number

times(Number $other)   X-Ref

param: Number $other
return: Number

dividedBy(Number $other)   X-Ref

param: Number $other
return: Number

equals(Number $other)   X-Ref

param: Number $other
return: bool

output(Compiler $compiler = null)   X-Ref
Output number

param: \ScssPhp\ScssPhp\Compiler $compiler
return: string

__toString()   X-Ref
{@inheritdoc}


coerceNumber(Number $other, $operation)   X-Ref

param: Number   $other
param: callable $operation
return: Number

coerceUnits(Number $other, $operation)   X-Ref

param: Number $other
param: callable $operation
return: mixed

valueInUnits(array $numeratorUnits, array $denominatorUnits)   X-Ref

param: string[] $numeratorUnits
param: string[] $denominatorUnits
return: int|float

multiplyUnits($value, array $numerators1, array $denominators1, array $numerators2, array $denominators2)   X-Ref

param: int|float $value
param: string[] $numerators1
param: string[] $denominators1
param: string[] $numerators2
param: string[] $denominators2
return: Number

getConversionFactor($unit1, $unit2)   X-Ref
Returns the number of [unit1]s per [unit2].

Equivalently, `1unit1 * conversionFactor(unit1, unit2) = 1unit2`.

param: string $unit1
param: string $unit2
return: float|int|null

getUnitString(array $numerators, array $denominators)   X-Ref
Returns unit(s) as the product of numerator units divided by the product of denominator units

param: string[] $numerators
param: string[] $denominators
return: string