An open API service indexing awesome lists of open source software.

https://github.com/itinance/tiny-state-machine


https://github.com/itinance/tiny-state-machine

Last synced: about 1 year ago
JSON representation

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') %}
```