Download the PHP package rokde/state-machine without Composer
On this page you can find all versions of the php package rokde/state-machine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rokde/state-machine
More information about rokde/state-machine
Files in rokde/state-machine
Package state-machine
Short Description A generic state machine implementation
License MIT
Informations about the package state-machine
State Machine
This package provides a generic implementation of the state machine pattern.
Real world examples
Article Lifecycle
Rules / Business process of an article lifecycle:
- A draft article can be submitted to get reviewed: Draft --Submit-> InReview
- Guard: a draft article need to have all the required meta data
- The article in review can be approved so it will be scheduled for publication: InReview --Approve-> Scheduled
- Guard: the published_at date has to be in the future or it gets published right away when it is null or in the past
- Scheduled articles gets published: Scheduled --Publish-> Published
- Guard: published_at is now or in the past
- Updating draft articles or articles in review will get back into draft status : Draft/InReview --Update-> Draft
- Guard: current acting user has to be the author of the article
- Already published articles can be archived: Published --Archive-> Archived
- no guard
If you want a diagram representation of your process workflow, then just transform the registry to mermaid:
This results in a diagramm like this:
The test can also be seen in ./tests/Feature/MermaidTest.php.
Order Lifecycle
This is built in the ./tests/Feature/TransitionTest.php.
Developer Happiness
๐งน Keep a modern codebase with Pint:
โ Run refactors using Rector
โ๏ธ Run static analysis using PHPStan:
โ Run unit tests using PEST
๐ Run the entire test suite: