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
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^9.5
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