piece/stagehand-fsm
最新稳定版本:v2.6.0
Composer 安装命令:
composer require piece/stagehand-fsm
包简介
A finite state machine
关键字:
README 文档
README
A finite state machine
Stagehand_FSM is a finite state machine.
Manual state management makes code complex, decreases intentionality. By using Stagehand_FSM, state management code can be declaratively represented in the form of FSM. This makes code simpler, increases intentionality.
Stagehand_FSM can be used as an infrastructure for domain-specific languages (DSLs). Examples are workflow engines such as Workflower, pageflow engines such as PHPMentorsPageflowerBundle.
<?php use Stagehand\FSM\StateMachine\StateMachineBuilder; $stateMachineBuilder = new StateMachineBuilder(); $stateMachineBuilder->addState('locked'); $stateMachineBuilder->addState('unlocked'); $stateMachineBuilder->setStartState('locked'); $stateMachineBuilder->addTransition('locked', 'insertCoin', 'unlocked'); $stateMachineBuilder->addTransition('unlocked', 'pass', 'locked'); $stateMachine = $stateMachineBuilder->getStateMachine(); $stateMachine->start(); echo $stateMachine->getCurrentState()->getStateID() . PHP_EOL; // "locked" $stateMachine->triggerEvent('insertCoin'); echo $stateMachine->getCurrentState()->getStateID() . PHP_EOL; // "unlocked" $stateMachine->triggerEvent('pass'); echo $stateMachine->getCurrentState()->getStateID() . PHP_EOL; // "locked"
Features
- Activities (do actions)
- Entry actions
- Exit actions
- Transition actions
- Transition logging
- Guards
- Initial pseudo state
- Final state
- User-defined payload
- User-defined event dispatcher for the state machine events
Installation
Stagehand_FSM can be installed using Composer.
Add the dependency to piece/stagehand-fsm into your composer.json file as the following:
Stable version:
composer require piece/stagehand-fsm "2.6.*"
Development version:
composer require phpmentors/stagehand-fsm "~3.0@dev"
Support
If you find a bug or have a question, or want to request a feature, create an issue or pull request for it on Issues.
Copyright
Copyright (c) 2006-2008, 2011-2018 KUBO Atsuhiro, All rights reserved.
License
统计信息
- 总下载量: 61.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 37
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2012-06-06