SlotFlow API Documentation

QuantityStateBatch
in package

Group of per-subject quantity states to be processed by the batch engine.

Tags
template
psalm-import-type

TInventoryTuple from QuantityState

TSlotPattern from SlotSpace

Table of Contents

Properties

$items  : array<string|int, mixed>

Methods

__construct()  : mixed
Create one batch from prebuilt per-subject items.
deltas()  : array<int, BatchQuantityStateDelta<string|int, TSubject>>
Flatten all item results to batch-scoped quantity-state deltas.
fromRows()  : self
Creates a QuantityStateBatch from an iterable of rows, using the provided closures to extract the necessary information.
items()  : array<string|int, BatchItem>
Return the batch items in subject order.
ledgerEntries()  : array<int, BatchLedgerEntry<string|int, TSubject>>
Flatten all item results to batch-scoped ledger entries.
of()  : self
Build a batch from per-subject quantity states you already hold.
one()  : self
Build a batch for one subject.
results()  : array<string|int, MovementResult|null}>
Returns the movement results for each item in the batch.

Properties

Methods

__construct()

Create one batch from prebuilt per-subject items.

public __construct(array<string|int, BatchItem$items) : mixed
Parameters
$items : array<string|int, BatchItem>
Tags
psalm-param

array<BatchItem<TSubject>> $items

fromRows()

Creates a QuantityStateBatch from an iterable of rows, using the provided closures to extract the necessary information.

public static fromRows(SlotSpace $space, iterable<string|int, mixed> $rows, Closure $subjectGetter, Closure $slotRowGetter, callable $quantityGetter) : self
Parameters
$space : SlotSpace
$rows : iterable<string|int, mixed>
$subjectGetter : Closure

closure to get the subject from a row

$slotRowGetter : Closure

closure to resolve slot dimensions and quantity from a row

$quantityGetter : callable

closure to get quantity from rows belonging to the same subject

Tags
psalm-template

TRow

TFactorySubject

psalm-param

iterable<TRow> $rows

\Closure(TRow): TFactorySubject $subjectGetter

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

psalm-return

self<TFactorySubject>

Return values
self

items()

Return the batch items in subject order.

public items() : array<string|int, BatchItem>
Tags
psalm-return

array<BatchItem<TSubject>>

Return values
array<string|int, BatchItem>

ledgerEntries()

Flatten all item results to batch-scoped ledger entries.

public ledgerEntries([array<string, mixed> $context = [] ]) : array<int, BatchLedgerEntry<string|int, TSubject>>
Parameters
$context : array<string, mixed> = []
Return values
array<int, BatchLedgerEntry<string|int, TSubject>>

of()

Build a batch from per-subject quantity states you already hold.

public static of(iterable<string|int, QuantityState}$entries) : self

The counterpart to fromRows(), for callers whose states did not come from rows — loaded from storage, carried over from a previous computation, or built by hand in a test. Without it the row shape is mandatory even when there are no rows.

Parameters
$entries : iterable<string|int, QuantityState}>

[subject, quantity, state]

Tags
psalm-template

TEntrySubject

psalm-param

iterable<array{TEntrySubject, int|float, QuantityState}> $entries

psalm-return

self<TEntrySubject>

Return values
self

one()

Build a batch for one subject.

public static one(mixed $subject, int|float $quantity, QuantityState $state) : self
Parameters
$subject : mixed
$quantity : int|float
$state : QuantityState
Tags
psalm-template

TOneSubject

psalm-param

TOneSubject $subject

psalm-return

self<TOneSubject>

Return values
self

results()

Returns the movement results for each item in the batch.

public results() : array<string|int, MovementResult|null}>
Tags
psalm-return

array<array{subject: TSubject, result: MovementResult|null}>

Return values
array<string|int, MovementResult|null}>
On this page

Search results