Finite\StateMachine\StateMachine::addState PHP Method

addState() public method

public addState ( $state )
    public function addState($state)
    {
        if (!$state instanceof StateInterface) {
            $state = new State($state);
        }
        $this->states[$state->getName()] = $state;
    }

Usage Example

コード例 #1
0
 public function testSkipEdgeException()
 {
     $visitor = $this->mockVisitor();
     $visitor->expects($this->once())->method('getEdgeAttributes')->willThrowException(new SkipElementException());
     $g = $this->providerGraphviz();
     $sm = new StateMachine();
     $sm->addState(new State('s1', State::TYPE_INITIAL));
     $sm->addState(new State('s2', State::TYPE_FINAL));
     $sm->addTransition('t12', 's1', 's2');
     $g->addVisitor($visitor);
     $dot = $g->render($sm);
     $this->assertNotContains('"t12"', $dot);
     $this->assertContains('"s1"', $dot);
     $this->assertContains('"s2"', $dot);
 }
All Usage Examples Of Finite\StateMachine\StateMachine::addState