QuantityStateBatch
in package
Group of per-subject quantity states to be processed by the batch engine.
Tags
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
$items
private
array<string|int, mixed>
$items
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
deltas()
Flatten all item results to batch-scoped quantity-state deltas.
public
deltas() : array<int, BatchQuantityStateDelta<string|int, TSubject>>
Return values
array<int, BatchQuantityStateDelta<string|int, TSubject>>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
Return values
selfitems()
Return the batch items in subject order.
public
items() : array<string|int, BatchItem>
Tags
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
Return values
selfone()
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
Return values
selfresults()
Returns the movement results for each item in the batch.
public
results() : array<string|int, MovementResult|null}>