Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sonsofphp/state-machine
[read-only] State Machine Component
https://github.com/sonsofphp/state-machine
php sons-of-php sonsofphp state-machine
Last synced: about 2 months ago
JSON representation
[read-only] State Machine Component
- Host: GitHub
- URL: https://github.com/sonsofphp/state-machine
- Owner: SonsOfPHP
- License: mit
- Created: 2024-09-03T00:50:45.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T19:47:35.000Z (4 months ago)
- Last Synced: 2024-09-10T22:43:53.710Z (4 months ago)
- Topics: php, sons-of-php, sonsofphp, state-machine
- Language: PHP
- Homepage: https://docs.sonsofphp.com/components/state-machine
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Sons of PHP - State Machine
===========================```php
'order',
'supports' => [
OrderInterface::class,
],
'transitions' => [
'create' => [
'from' => 'draft',
'to' => 'new',
],
'fulfill' => [
'from' => 'new',
'to' => 'fulfilled',
],
'cancel' => [
'from' => ['draft', 'new', 'fulfilled'],
'to' => 'fulfilled',
],
],
]);// Check if state can change
$sm->can($order, 'create');// Apply transition
$sm->apply($order, 'fulfil');// Get Current State
$sm->getState($order);
```## Learn More
* [Documentation][docs]
* [Contributing][contributing]
* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo]
* Get Help & Support using [Discussions][discussions][discussions]: https://github.com/orgs/SonsOfPHP/discussions
[mother-repo]: https://github.com/SonsOfPHP/sonsofphp
[contributing]: https://docs.sonsofphp.com/contributing/
[docs]: https://docs.sonsofphp.com/components/state-machine/
[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AStateMachine
[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AStateMachine