Index

Units

MMO\math\helpers · 1 symbol · generated 30 Sep 2026

class

Units

Units.php:14

Holds a list of UnitVector

class MMO\math\helpers\Units implements Countable, Stringable, ArrayAccess, IteratorAggregate
Namespace
MMO\math\helpers
Implements
Countable, Stringable, ArrayAccess, IteratorAggregate

Index

content
clear()
Compatible($a, $b) static
convertFactor($to)Get the conversion factor between two units WARNING: units MUST be compatible
count()
debugName()
divideBy($factor)
divideUnit($unit, $power, $factor)
From($value, $clone) static
getFactor()
getIterator()\IteratorAggregate::getIterator
getUnit($value, $create)Get a unit vector from a unit
getUnits()
hasUnit($value)
isCompatible($units)Tests if compatible with another units.
isConstant()
isPrimitive()
isSameUnits($units, $checkPower)
isTime()
LoopBinomialPower($power, $vectors) staticExpand a binomial to the power using the binomial theorem (a+b+...)^n
multiplyBy($factor)Multiply this unit by a factor or another unit
multiplyUnit($unit, $power, $factor)
numberValue()Get the value of these vectors.
offsetExists($key)\ArrayAccess::offsetExists
offsetGet($key)\ArrayAccess::offsetGet
offsetSet($key, $value)\ArrayAccess::offsetSet
offsetUnset($key)\ArrayAccess::offsetUnset
powerBy($power)
removeUnit($unit)
standard()Return primitives units or a float factor if it has no units
toNumber()
unitFactor($unit)
__clone()
__construct($units)
__toString()

Properties1

content

protected array $content = []
Type
array

Methods34

convertFactor($to)

Units.php:348

Get the conversion factor between two units WARNING: units MUST be compatible

function convertFactor(?self $to): float
$tonull | self
returnsfloat

divideUnit($unit, $power, $factor)

Units.php:261
function divideUnit( MMO\math\interfaces\iUnit|MMO\math\helpers\UnitVector|string $unit, float $power = 1.0, MMO\math\enums\cPrefix|float $factor = 1.0 ): MMO\math\helpers\UnitVector
$unitiUnit | UnitVector | string
$power = 1.0float
$factor = 1.0cPrefix | float
returnsUnitVector

From($value, $clone)

staticUnits.php:22
static function From(mixed $value, bool $clone = true): ?self
$valuemixed
$clone = truebool
returnsnull | self

getUnit($value, $create)

Units.php:217

Get a unit vector from a unit

function getUnit(MMO\math\interfaces\iUnit|string $value, bool $create = false): ?MMO\math\helpers\UnitVector
$valueiUnit | string
$create = falsebool
returnsnull | UnitVector

isCompatible($units)

Units.php:378

Tests if compatible with another units.

function isCompatible(?self $units): boolUnits are compatible when their standard units are the same with the same powers. Factor are not checked for compatibility.
$unitsnull | self
returnsbool

isSameUnits($units, $checkPower)

Units.php:195
function isSameUnits( MMO\math\interfaces\iUnit|MMO\math\helpers\UnitVector|self|string $units, bool $checkPower = true ): bool
$unitsiUnit | UnitVector | self | string
$checkPower = truebool
returnsbool

LoopBinomialPower($power, $vectors)

staticUnits.php:49

Expand a binomial to the power using the binomial theorem (a+b+...)^n

static function LoopBinomialPower(int $power, MMO\math\helpers\UnitVector|self|int|float ...$vectors): Generator
See
https://en.wikipedia.org/wiki/Binomial_theorem
$powerint
...$vectorsUnitVector | self | int | float
returnsGenerator
foreach (\MMO\math\helpers\Units::LoopBinomialPower(2, new UnitVector('a'), new UnitVector('b'), new UnitVector('c')) as $unit) { echo ' + ' . $unit; } => + a² + b² + c² + 2bc + 2ac + 2ab

multiplyBy($factor)

Units.php:281

Multiply this unit by a factor or another unit

function multiplyBy( MMO\math\interfaces\iUnit|MMO\math\helpers\UnitVector|self|string|int|float $factor ): self
$factoriUnit | UnitVector | self | string | int | float
returnsself

multiplyUnit($unit, $power, $factor)

Units.php:245
function multiplyUnit( MMO\math\interfaces\iUnit|MMO\math\helpers\UnitVector|string $unit, float $power = 1.0, MMO\math\enums\cPrefix|float $factor = 1.0 ): MMO\math\helpers\UnitVector
$unitiUnit | UnitVector | string
$power = 1.0float
$factor = 1.0cPrefix | float
returnsUnitVector

numberValue()

Units.php:180

Get the value of these vectors.

function numberValue(): int|float|nullUsed by polynome when the unit is a UnitNumber
returnsint | float | null

offsetExists($key)

Units.php:459

\ArrayAccess::offsetExists

function offsetExists(mixed $key): bool
$keymixed
returnsbool

offsetSet($key, $value)

Units.php:440

\ArrayAccess::offsetSet

function offsetSet(mixed $key, mixed $value): void
$keymixed
$valuemixed
returnsvoid

offsetUnset($key)

Units.php:421

\ArrayAccess::offsetUnset

function offsetUnset(mixed $key): void
$keymixed
returnsvoid

standard()

Units.php:321

Return primitives units or a float factor if it has no units

function standard(): static|float
returnsstatic | float