Documentations › mmo.math › php › helpers Units MMO\math\helpers · 1 symbol · generated 30 Sep 2026
Holds a list of UnitVector
class MMO\math\helpers\Units
implements Countable,
Stringable,
ArrayAccess,
IteratorAggregate Namespace MMO\math\helpersImplements 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) static Expand 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 protected array $content = [] Type array Methods34 function clear(): void static function Compatible(mixed $a, mixed $b): bool Get the conversion factor between two units WARNING: units MUST be compatible
function convertFactor(?self $to): float function count(): int function debugName(): string function divideBy(
MMO\math\interfaces\iUnit|MMO\math\helpers\UnitVector|self|string|int|float $factor
): self 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 static function From(mixed $value, bool $clone = true): ?self function getFactor(): float \IteratorAggregate::getIterator
function getIterator(): Traversable Get a unit vector from a unit
function getUnit(MMO\math\interfaces\iUnit|string $value, bool $create = false): ?MMO\math\helpers\UnitVector function getUnits(): array function hasUnit(MMO\math\interfaces\iUnit|string $value): bool Tests if compatible with another units.
function isCompatible(?self $units): bool Units are compatible when their standard units are the same with the same powers. Factor are not checked for compatibility. function isConstant(): bool function isPrimitive(): bool function isSameUnits(
MMO\math\interfaces\iUnit|MMO\math\helpers\UnitVector|self|string $units,
bool $checkPower = true
): bool function isTime(): bool 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_theoremforeach (\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
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 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 Get the value of these vectors.
function numberValue(): int|float|null Used by polynome when the unit is a UnitNumber \ArrayAccess::offsetExists
function offsetExists(mixed $key): bool \ArrayAccess::offsetGet
function offsetGet(mixed $key): mixed \ArrayAccess::offsetSet
function offsetSet(mixed $key, mixed $value): void \ArrayAccess::offsetUnset
function offsetUnset(mixed $key): void function powerBy(float $power): self function removeUnit(MMO\math\interfaces\iUnit|string $unit): ?MMO\math\helpers\UnitVector Return primitives units or a float factor if it has no units
function standard(): static|float function toNumber(): MMO\math\helpers\Number|MMO\math\operations\ArithmeticOperation function unitFactor(MMO\math\interfaces\iUnit|string|null $unit = null): MMO\math\operations\ArithmeticOperation|MMO\math\helpers\Number|float function __clone() function __construct(MMO\math\interfaces\iUnit|MMO\math\helpers\UnitVector|string ...$units) function __toString(): string