Index

Operation

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

class

Operation

Operation.php:16
class MMO\math\operations\Operation implements MMO\math\interfaces\iOperation, MMO\core\interfaces\iArray, MMO\math\interfaces\iSimpleDomain, MMO\math\interfaces\iListenable, MMO\core\interfaces\iComparable, Stringable use MMO\core\classes\tArray
Namespace
MMO\math\operations
Implements
iOperation, iArray, iSimpleDomain, iListenable, iComparable, Stringable
Uses traits
tArray

Index

content
operator
addListener($callable, $target)
canCommute()
canInverseEquality()
clear()Empty the underlying content, keeping the object itself.
commute()
compareTo($value)
contains($num)Test if operation contains the number or an instance of it
count()\Countable::count
debugName()
execute()
extract($num, $result)
getIterator()\IteratorAggregate::getIterator
getOperator()
hasUnits()
intervals()
inverseEquality($value)
isEmpty()
jsonSerialize()\JsonSerializable::jsonSerialize -- the raw content is returned as-is (not recursively converted), so json_encode() relies on any nested iArray values being JsonSerializable themselves.
keys()
loadArray($data)Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g.
loopNumber()
numberValue()
offsetExists($key)\ArrayAccess::offsetExists
offsetGet($key)\ArrayAccess::offsetGet
offsetSet($key, $value)\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.
offsetUnset($key)\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain …
removeListener($callable)
simplify()
toArray()Convert the content to a plain array, recursively converting any nested iArray value (e.g.
units()Get the units of this operation.
__construct($operator, $args)
__toString()

Properties2

content

protected $content = []

operator

protected $operator = null

Methods32

clear()

tArray.php:25

Empty the underlying content, keeping the object itself.

function clear()
returns
$bag->clear(); // count($bag) === 0 afterwards

contains($num)

Operation.php:147

Test if operation contains the number or an instance of it

function contains(MMO\math\interfaces\iNumber|string $num): bool
$numiNumber | stringa classname or a number to look for
returnsbool

isEmpty()

tArray.php:33
function isEmpty()
returnstrue if the underlying content has no elements
$bag->isEmpty(); // true right after clear(), false as soon as an item is set

jsonSerialize()

tArray.php:43

\JsonSerializable::jsonSerialize -- the raw content is returned as-is (not recursively converted), so json_encode() relies on any nested iArray values being JsonSerializable themselves.

function jsonSerialize(): mixed
returnsmixed
json_encode($bag); // e.g. '{"x":1,"0":2}'

keys()

tArray.php:82
function keys(): array
returnsarraythe list of keys currently set
$bag->keys(); // e.g. ['x', 0]

loadArray($data)

tArray.php:71

Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g. for validation or type coercion, is honored for every entry).

function loadArray(array $data): static
$dataarray
returnsstatic$this, for chaining
$bag->loadArray(['x' => 1, 'y' => 2]); // equivalent to $bag['x'] = 1; $bag['y'] = 2;

offsetExists($key)

tArray.php:130

\ArrayAccess::offsetExists

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

offsetSet($key, $value)

tArray.php:122

\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.

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

offsetUnset($key)

tArray.php:107

\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain PHP list; on an associative array, the key is simply removed.

function offsetUnset(mixed $key): void
$keymixed
returnsvoid
unset($bag[0]); // on a list: every following index shifts down by one, like array_splice()

toArray()

tArray.php:56

Convert the content to a plain array, recursively converting any nested iArray value (e.g. another object using this same trait) into its own plain-array form as well.

function toArray(): array
returnsarray
$inner = new Bag(); $inner['a'] = 1; $outer = new Bag(); $outer['inner'] = $inner; $outer->toArray(); // ['inner' => ['a' => 1]] -- $inner is recursively expanded, not left as an object

units()

Operation.php:57

Get the units of this operation.

function units(): ?MMO\math\helpers\UnitsIf the operator is Arithmetic, the first 2 arguments are used to compute the units
returnsnull | Units