Skip to content

php-pair-programming-budapest/state-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

State machine

Usage examples

$inStock = new StatusObject('in-stock');
$ordered = new StatusObject('ordered');
$shipped = new StatusObject('shipped');

$inStock->addNextStatus($ordered);

$ordered->addNextStatus($shipped);
$ordered->addNextStatus($inStock); // in case of cancelling the order

$stateMachine = new StateMachine();

$model = new Order(); 
$model->setState($inStock);

if ($model->getState()->canChangeStatus($ordered)) {
	$stateMachine->process($model, $ordered);
}

Test

Build Status

Releases

No releases published

Packages

No packages published

Languages