Skip to content

phwoolcon/fsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phwoolcon Finite State Machine

Build Status Code Coverage License

See the definition of Finite-state machine on Wikipedia

Installation

Add this library to your project by composer:

composer require "phwoolcon/fsm"

Usage

<?php
use Phwoolcon\Fsm\StateMachine;
$fsm = StateMachine::create([
    'foo' => [
        'process' => 'bar',
    ],
    'bar' => [
        'process2' => 'hello',
        'process3' => 'world',
    ],
]);
echo $fsm->getCurrentState();   // prints foo
echo $fsm->next();              // prints bar
echo $fsm->do('process2');      // prints hello