Skip to content
docsv0.1.0

DefinitionContract

The narrow slice of a process definition {@see Reducer} needs to fold events into a {@see ProcessState}: where a process starts, and which transitions are available from a given state. Deliberately smaller than a full process definition (states, terminality, gates, inputs) — {@see ProcessDefinition} (composing `milpa/workflow`'s `StateDefinition`/`TransitionDefinition`) implements this contract on top of its richer model, but any other state-machine representation can drive {@see Reducer} the same way by implementing this interface directly.

DefinitionContract::initialState()

abstract public function initialState(): string

The state a fresh process instance starts in.

DefinitionContract::transitionsFrom()

abstract public function transitionsFrom(string $state): array

The transitions available from `$state`, each naming the event `type` that triggers it and the state it leads to. An empty list means `$state` has no outgoing transitions (e.g. it is terminal, or simply has none defined from it).

Parameters

Parameters of transitionsFrom()
NameTypeDescription
$statestring