Inventory
extends QuantityState
in package
Backward-compatible commerce-oriented alias for QuantityState.
use QuantityState instead
Table of Contents
Methods
- __construct() : mixed
- add() : void
- addFromRows() : static
- Add quantities from rows using a resolver that yields slot tuples.
- all() : array<string, int|float>
- Return all non-zero stored quantities keyed by slot key.
- copy() : static
- Clone the quantity state and remembered slot attributes.
- fromRows() : static
- Build a new quantity state from rows using a tuple resolver.
- get() : int|float
- Get the quantity currently stored at one slot.
- getSum() : int|float
- Sum quantities across one or more slots or slot patterns.
- setSlotQtty() : void
- Set the quantity for a given slot, replacing any existing quantity.
- setTuple() : void
- Set the quantity state using a list of slot-quantity tuples, replacing any existing quantities.
- slotAttribute() : mixed
- Read one remembered slot attribute with an optional default.
- slotAttributes() : array<string, mixed>
- Return per-slot attributes remembered during ingestion or tuple loading.
Methods
__construct()
public
__construct(SlotSpace $space[, array<string|int, Slot, int|float}> $tuples = [] ]) : mixed
Parameters
- $space : SlotSpace
- $tuples : array<string|int, Slot, int|float}> = []
Tags
add()
public
add(Slot $slot, int|float $delta) : void
Parameters
- $slot : Slot
- $delta : int|float
Tags
addFromRows()
Add quantities from rows using a resolver that yields slot tuples.
public
addFromRows(iterable<string|int, mixed> $rows, Closure $resolver) : static
Parameters
- $rows : iterable<string|int, mixed>
- $resolver : Closure
Tags
Return values
staticall()
Return all non-zero stored quantities keyed by slot key.
public
all() : array<string, int|float>
Tags
Return values
array<string, int|float>copy()
Clone the quantity state and remembered slot attributes.
public
copy() : static
Return values
staticfromRows()
Build a new quantity state from rows using a tuple resolver.
public
static fromRows(SlotSpace $space, iterable<string|int, mixed> $rows, Closure $resolver) : static
Parameters
- $space : SlotSpace
- $rows : iterable<string|int, mixed>
- $resolver : Closure
Tags
Return values
staticget()
Get the quantity currently stored at one slot.
public
get(Slot|array<string|int, string|null>|string|null $slot) : int|float
Parameters
- $slot : Slot|array<string|int, string|null>|string|null
Tags
Return values
int|floatgetSum()
Sum quantities across one or more slots or slot patterns.
public
getSum(Slot|array<string|int, string|null>|string|null ...$slotPatterns) : int|float
Overlapping patterns are de-duplicated by slot key so each matching slot is counted at most once in the returned total.
Parameters
- $slotPatterns : Slot|array<string|int, string|null>|string|null
Tags
Return values
int|floatsetSlotQtty()
Set the quantity for a given slot, replacing any existing quantity.
public
setSlotQtty(Slot $slot, int|float $quantity) : void
Parameters
- $slot : Slot
- $quantity : int|float
setTuple()
Set the quantity state using a list of slot-quantity tuples, replacing any existing quantities.
public
setTuple(array<string|int, Slot, int|float}> $slots) : void
Parameters
- $slots : array<string|int, Slot, int|float}>
Tags
slotAttribute()
Read one remembered slot attribute with an optional default.
public
slotAttribute(Slot $slot, string $name[, mixed $default = null ]) : mixed
Parameters
- $slot : Slot
- $name : string
- $default : mixed = null
slotAttributes()
Return per-slot attributes remembered during ingestion or tuple loading.
public
slotAttributes(Slot $slot) : array<string, mixed>
Parameters
- $slot : Slot