Skip to content

fissible/php7-machines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php7-machines

Implementation of a finite state machine in PHP7.

Usage

A turnstile abstraction:

use Machines\State;
use Machines\StateMachine;
use Machines\Transition;

$Locked = new State('Locked');
$Unlocked = new State('Unlocked');

$Locked->setTransitions([
    new Transition(new MatchAcceptor('coin'), $Unlocked)
]);
$Unlocked->setTransitions([
    new Transition(new MatchAcceptor('push'), $Locked)
]);

$machine = new StateMachine([$Locked, $Unlocked]);

$machine->input('coin');

$machine->input('push');

About

Implementation of a finite state machine in PHP7.

Resources

License

Stars

Watchers

Forks

Packages

No packages published