/** * Adds the states as nodes. * * @param \Finite\StateMachine\StateMachineInterface $stateMachine */ private function addNodes(StateMachineInterface $stateMachine) { $states = $stateMachine->getStates(); foreach ($states as $name) { $this->graph->beginNode($name, $this->getNodeAttributes($stateMachine, $name))->end(); } }
private function addStates(Digraph $graph, StateMachine $stateMachine) { foreach ($stateMachine->getStates() as $stateName) { $state = $stateMachine->getState($stateName); $graph->beginNode($stateName, $this->getStateAttributes($state))->end(); } }
/** * Adds the states as nodes. * * @param \Finite\StateMachine\StateMachineInterface $stateMachine */ private function addNodes(StateMachineInterface $stateMachine) { $states = $stateMachine->getStates(); foreach ($states as $name) { $state = $stateMachine->getState($name); $attributes = $this->getDefaultNodeAttributes($state, $stateMachine); if ($this->visitors) { try { foreach ($this->visitors as $visitor) { $attributes = $visitor->getNodeAttributes($attributes, $state, $stateMachine); } } catch (SkipElementException $ex) { continue; } } $this->graph->beginNode($name, $attributes)->end(); } }
public function testFluidInterfaceVerbose() { $graph = new Digraph('G'); $graph->beginNode('A')->attribute('color', 'red')->end()->beginEdge(array('A', 'B'))->attribute('color', 'blue')->end(); $this->assertCount(2, $instructions = $graph->getInstructions(), "2 instructions"); $this->assertTrue($instructions[0] instanceof Node, "First instructions is a node"); $this->assertEquals('A', $instructions[0]->getId(), "Node identifier"); $this->assertEquals('red', $instructions[0]->getAttributes()->get('color'), "Node attribute"); $this->assertTrue($instructions[1] instanceof DirectedEdge, "Second instructions is a node"); $this->assertEquals('blue', $instructions[1]->getAttributes()->get('color'), "Edge attribute"); }