izzum\statemachine\Transition::getCommand PHP Method

getCommand() public method

the Command will be configured with the 'reference' of the stateful object. In case there have been multiple commands as input (',' seperated), this method will return a Composite command.
public getCommand ( Context $context ) : izzum\command\ICommand
$context Context
return izzum\command\ICommand
    public function getCommand(Context $context)
    {
        return Utils::getCommand($this->command, $context);
    }

Usage Example

 /**
  * @test
  */
 public function shouldExpectExceptionsWhenCallingPublicMethodsWithNonDefaultConstructorValues()
 {
     $from = new State('a');
     $to = new State('b');
     $rule = 'izzum\\rules\\BOGUS';
     $command = 'izzum\\command\\BOGUS';
     $object = new Context(new Identifier(Identifier::NULL_ENTITY_ID, Identifier::NULL_STATEMACHINE));
     $transition = new Transition($from, $to, null, $rule, $command);
     $this->assertEquals($from . '_to_' . $to, $transition->getName());
     $this->assertEquals($from, $transition->getStateFrom());
     $this->assertEquals($to, $transition->getStateTo());
     $this->assertContains($transition->getName(), $transition->toString());
     try {
         $command = $transition->getCommand($object);
         $this->fail('should not come here');
     } catch (Exception $e) {
         $this->assertEquals(Exception::COMMAND_CREATION_FAILURE, $e->getCode());
     }
     try {
         $rule = $transition->getRule($object);
         $this->fail('should not come here');
     } catch (Exception $e) {
         $this->assertEquals(Exception::RULE_CREATION_FAILURE, $e->getCode());
     }
 }