PHP Interface Finite\StateMachine\StateMachineInterface

Author: Yohan Giarelli ([email protected])
Datei anzeigen Open project: yohang/finite Interface Usage Examples

Public Methods

Method Description
addState ( string | Finite\State\StateInterface $state )
addTransition ( string | Finite\Transition\TransitionInterface $transition, string | null $initialState = null, string | null $finalState = null )
apply ( string $transitionName, array $parameters = [] ) : mixed Apply a transition.
can ( string | Finite\Transition\TransitionInterface $transition, array $parameters = [] ) : boolean Returns if the transition is applicable.
findStateWithProperty ( string $property, mixed $value = null ) : boolean Find a state which have a given property, with an optional given value.
getCurrentState ( ) : Finite\State\StateInterface
getDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface
getGraph ( ) : string
getObject ( ) : object
getState ( string $name ) : Finite\State\StateInterface
getStates ( ) : array Returns an array containing all the states names.
getTransition ( string $name ) : Finite\Transition\TransitionInterface Returns a transition by its name.
getTransitions ( ) : array Returns an array containing all the transitions names.
hasStateAccessor ( ) : boolean
initialize ( ) Initialize the State Machine current state.
setGraph ( string $graph )
setObject ( object $object )
setStateAccessor ( Finite\State\Accessor\StateAccessorInterface $stateAccessor )

Method Details

addState() public method

public addState ( string | Finite\State\StateInterface $state )
$state string | Finite\State\StateInterface

addTransition() public method

public addTransition ( string | Finite\Transition\TransitionInterface $transition, string | null $initialState = null, string | null $finalState = null )
$transition string | Finite\Transition\TransitionInterface
$initialState string | null
$finalState string | null

apply() public method

Apply a transition.
public apply ( string $transitionName, array $parameters = [] ) : mixed
$transitionName string
$parameters array
return mixed

can() public method

Returns if the transition is applicable.
public can ( string | Finite\Transition\TransitionInterface $transition, array $parameters = [] ) : boolean
$transition string | Finite\Transition\TransitionInterface
$parameters array
return boolean

findStateWithProperty() public method

It is useful for looking for objects having a given property in database for example.
public findStateWithProperty ( string $property, mixed $value = null ) : boolean
$property string
$value mixed
return boolean

getCurrentState() public method

public getCurrentState ( ) : Finite\State\StateInterface
return Finite\State\StateInterface

getDispatcher() public method

public getDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface
return Symfony\Component\EventDispatcher\EventDispatcherInterface

getGraph() public method

public getGraph ( ) : string
return string

getObject() public method

public getObject ( ) : object
return object

getState() public method

public getState ( string $name ) : Finite\State\StateInterface
$name string
return Finite\State\StateInterface

getStates() public method

Returns an array containing all the states names.
public getStates ( ) : array
return array

getTransition() public method

Returns a transition by its name.
public getTransition ( string $name ) : Finite\Transition\TransitionInterface
$name string
return Finite\Transition\TransitionInterface

getTransitions() public method

Returns an array containing all the transitions names.
public getTransitions ( ) : array
return array

hasStateAccessor() public method

public hasStateAccessor ( ) : boolean
return boolean

initialize() public method

Initialize the State Machine current state.
public initialize ( )

setGraph() public method

public setGraph ( string $graph )
$graph string

setObject() public method

public setObject ( object $object )
$object object

setStateAccessor() public method

public setStateAccessor ( Finite\State\Accessor\StateAccessorInterface $stateAccessor )
$stateAccessor Finite\State\Accessor\StateAccessorInterface