SlotFlow API Documentation

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
psalm-param

list<TInventoryTuple> $tuples

add()

public add(Slot $slot, int|float $delta) : void
Parameters
$slot : Slot
$delta : int|float
Tags
psalm-param

TQtty $delta

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
psalm-template

TRow

psalm-param

iterable<TRow> $rows

psalm-param

(\Closure(TRow): list<TInventoryTuple>|\Closure(TRow, SlotSpace): list<TInventoryTuple>) $resolver

Return values
static

all()

Return all non-zero stored quantities keyed by slot key.

public all() : array<string, int|float>
Tags
psalm-return

array<string, TQtty>

Return values
array<string, int|float>

copy()

Clone the quantity state and remembered slot attributes.

public copy() : static
Return values
static

fromRows()

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
psalm-template

TRow

psalm-param

iterable<TRow> $rows

psalm-param

(\Closure(TRow): list<TInventoryTuple>|\Closure(TRow, SlotSpace): list<TInventoryTuple>) $resolver

Return values
static

get()

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
psalm-param

Slot|TSlotPattern $slot

psalm-return

TQtty

Return values
int|float

getSum()

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
psalm-param

Slot|TSlotPattern ...$slotPatterns

psalm-return

TQtty

Return values
int|float

setSlotQtty()

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
psalm-param

list<TInventoryTuple> $slots

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
Return values
array<string, mixed>

        
On this page

Search results