grifix/state-machine

此包已被弃用,不再维护。未建议替代包。

非常简单的状态机

维护者

详细信息

gitlab.com/grifix/state-machine

3.0.1 2022-07-03 06:39 UTC

This package is auto-updated.

Last update: 2023-07-26 07:07:16 UTC


README

非常简单的状态机

安装

composer require grifix/state-machine

用法

<?php

$stateMachine = new StateMachine(
    new Transition('new', 'active'),
    new Transition('active', 'closed', 'new')
);
$stateMachine->isTransitionPossible('new', 'active') //true
$stateMachine->isTransitionPossible('active', 'new') //true
$stateMachine->isTransitionPossible('new', 'closed') //false
$stateMachine->isTransitionPossible('closed', 'new') //false
$stateMachine->assertTransitionIsPossible('new', 'closed') //throws TransitionIsNotPossibleException