public function initialize($stateName = null)
    {
        if (!$stateName) {
            $stateName = $this->initialStateName;
        }

        if (empty($this->states[$stateName])) {
            throw new \Exception('Passed name of current state is wrong');
        }

        $this->currentState = $this->states[$stateName];

        return $this;
    }
public function initialize($stateName = null)
    {
        if (!$stateName) {
            $stateName = $this->initialStateName;
        }

        if (empty($this->states[$stateName])) {
            throw new \Exception('Passed name of current state is wrong');
        }

        $this->currentState = $this->states[$stateName];

        return $this;
    }
public function initialize ( $ stateName = null ) { if ( ! $ stateName ) { $ stateName = $ this -> initialStateName ; } if ( empty ( $ this -> states [ $ stateName ] ) ) { throw new \ Exception ( 'Passed name of current state is wrong' ) ; } $ this -> currentState = $ this -> states [ $ stateName ] ; return $ this ; }
Initialize machine by current state.

@param $stateName state name that will set as current. If omited, then
initial state will be set as current
@return Machine
@throws \Exception
Initialize machine by current state .