$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);
}
-
Notifications
You must be signed in to change notification settings - Fork 0
State machine
License
php-pair-programming-budapest/state-machine
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
State machine
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published