grifix/state-machine

This package is abandoned and no longer maintained. No replacement package was suggested.

Very simple state machine

3.0.1 2022-07-03 06:39 UTC

This package is auto-updated.

Last update: 2023-07-26 07:07:16 UTC


README

Very simple state machine

Installation

composer require grifix/state-machine

Usage

<?php

$stateMachine = new StateMachine(
    new Transition('new', 'active'),
    new Transition('active', 'closed', 'new')
);
$stateMachine->isTransitionPossible('new', 'active') //true
$stateMachine->isTransitionPossible('active', 'new') //true
$stateMachine->isTransitionPossible('new', 'closed') //false
$stateMachine->isTransitionPossible('closed', 'new') //false
$stateMachine->assertTransitionIsPossible('new', 'closed') //throws TransitionIsNotPossibleException