https://github.com/itinance/tiny-state-machine
https://github.com/itinance/tiny-state-machine
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/itinance/tiny-state-machine
- Owner: itinance
- License: mit
- Created: 2016-02-08T08:53:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-08T16:26:02.000Z (over 10 years ago)
- Last Synced: 2024-10-29T11:29:27.361Z (over 1 year ago)
- Language: PHP
- Size: 41 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TinyStateMachine
## Installation
composer require itinance/tiny-state-machine
## Usage
This StateMachine enables to set some state in an application and to request this state elsewhere, even in Twig.
Setting state:
```
StateMachine::instance()->setState('Foobar');
```
Setting state with value:
```
StateMachine::instance()->setState('Foobar', 'barfoo');
```
Request state:
```
StateMachine::instance()->getState('Foobar' /* , $default */);
StateMachine::instance()->hasState('Foobar');
StateMachine::instance()->hasStateWithValue('Foobar', 'barfoo');
```
Twig:
```
{% if hasState('Foobar') %}
```