izzum\statemachine\Transition::__construct PHP Method

__construct() public method

public __construct ( State $state_from, State $state_to, string $event = null, string $rule = self::RULE_EMPTY, string $command = self::COMMAND_EMPTY, callable $callable_guard = self::CALLABLE_NULL, callable $callable_transition = self::CALLABLE_NULL )
$state_from State
$state_to State
$event string optional: an event name by which this transition can be triggered
$rule string optional: one or more fully qualified Rule (sub)class name(s) to check to see if we are allowed to transition. This can actually be a ',' seperated string of multiple rules that will be applied as a chained 'and' rule.
$command string optional: one or more fully qualified Command (sub)class name(s) to execute for a transition. This can actually be a ',' seperated string of multiple commands that will be executed as a composite.
$callable_guard callable optional: a php callable to call. eg: "function(){echo 'closure called';};"
$callable_transition callable optional: a php callable to call. eg: "izzum\MyClass::myStaticMethod"
    public function __construct(State $state_from, State $state_to, $event = null, $rule = self::RULE_EMPTY, $command = self::COMMAND_EMPTY, $callable_guard = self::CALLABLE_NULL, $callable_transition = self::CALLABLE_NULL)
    {
        $this->state_from = $state_from;
        $this->state_to = $state_to;
        $this->setRuleName($rule);
        $this->setCommandName($command);
        $this->setGuardCallable($callable_guard);
        $this->setTransitionCallable($callable_transition);
        // setup bidirectional relationship with state this transition
        // originates from. only if it's not a regex or final state type
        if (!$state_from->isRegex() && !$state_from->isFinal()) {
            $state_from->addTransition($this);
        }
        // set and sanitize event name
        $this->setEvent($event);
    }