PHP Класс izzum\statemachine\utils\Utils

Автор: Rolf Vreijdenberger
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
checkCallable ( callable $callable, string $type, string $info, Context $context = null ) : boolean
checkConfiguration ( StateMachine $machine ) : Exception[] Checks a fully loaded statemachine for a valid configuration.
getAllRegexMatchingStates ( State $regex, State[] $targets ) : State[] get all states that match a possible regex state from the set of states provided
getCommand ( string $command_name, Context $context ) : izzum\command\ICommand returns the associated Command for the entry/exit/transition action on a State or a Transition.
getTransitionName ( string $from, string $to ) : string gets the transition name by two state names, using the default convention for a transition name (which is concatenating state-from to state-to with '_to_')
matchesRegex ( State $regex, State $target ) : boolean does an input regex state match a target states' name?
wrapToStateMachineException ( Exception $e, integer $code, $throw = false ) : Exception Always returns an izzum exception (converts a non-izzum exception to an izzum exception).

Приватные методы

Метод Описание
getExceptionForCheckingCallable ( callable $callable, string $type, string $info, Context $context = null ) : Exception

Описание методов

checkCallable() публичный статический Метод

public static checkCallable ( callable $callable, string $type, string $info, Context $context = null ) : boolean
$callable callable
$type string a type description of the callable eg: State::CALLABLE_ENTRY
$info string extra info for exception message purposes
$context izzum\statemachine\Context optional: the context the callable is called in
Результат boolean

checkConfiguration() публичный статический Метод

This is useful in a debug situation so you can check for the validity of rules, commands and callables in guard logic, transition logic and state entry/exit logic before they hit a This does not instantiate any objects. It just checks if callables can be found and if classes for rules and commands can be found
public static checkConfiguration ( StateMachine $machine ) : Exception[]
$machine izzum\statemachine\StateMachine
Результат izzum\statemachine\Exception[] an array of exceptions if anything is wrong with the configuration

getAllRegexMatchingStates() публичный статический Метод

get all states that match a possible regex state from the set of states provided
public static getAllRegexMatchingStates ( State $regex, State[] $targets ) : State[]
$regex izzum\statemachine\State a possible regex state.
$targets izzum\statemachine\State[] all target State instances that we check the regex against.
Результат izzum\statemachine\State[] an array of State instances from the $targets State instances that matched the (negated) regex, or the $regex State if it was not a regex State after all.

getCommand() публичный статический Метод

the Command will be configured with the 'reference' of the stateful object
public static getCommand ( string $command_name, Context $context ) : izzum\command\ICommand
$command_name string entry~,exit~ or transition command name. multiple commands can be split by a ',' in which case a composite command will be returned.
$context izzum\statemachine\Context to be able to get the entity
Результат izzum\command\ICommand

getTransitionName() публичный статический Метод

gets the transition name by two state names, using the default convention for a transition name (which is concatenating state-from to state-to with '_to_')
public static getTransitionName ( string $from, string $to ) : string
$from string the state from which the transition is made
$to string the state to which the transition will be made
Результат string _to_

matchesRegex() публичный статический Метод

does an input regex state match a target states' name?
public static matchesRegex ( State $regex, State $target ) : boolean
$regex izzum\statemachine\State the regex state
$target izzum\statemachine\State the state to match the regular expression to
Результат boolean

wrapToStateMachineException() публичный статический Метод

optionally throws it.
public static wrapToStateMachineException ( Exception $e, integer $code, $throw = false ) : Exception
$e Exception
$code integer
Результат izzum\statemachine\Exception