public function testGettersSetters()
 {
     $callable = function () {
     };
     $definition = new CommandDefinition('animal', ['name'], $callable);
     $this->assertSame($definition->getName(), 'animal');
     $this->assertSame(['name'], $definition->getRequiredArgs());
     $this->assertSame($callable, $definition->getCommandCallable());
 }
 public function testGettersSettersWithObjArgs()
 {
     $callable = function () {
     };
     $definition = new CommandDefinition('animal', [new CommandArgument('name')], $callable);
     $this->assertSame($definition->getName(), 'animal');
     $requiredArgs = $definition->getRequiredArgs();
     $this->assertCount(1, $requiredArgs);
     $this->assertInstanceOf(CommandArgument::class, $requiredArgs[0]);
     $this->assertSame('name', $requiredArgs[0]->getName());
     $this->assertSame($callable, $definition->getCommandCallable());
 }
 /**
  * @param CommandDefinition $command
  * @param array $args
  * @return int
  */
 private function resolveCallable(CommandDefinition $command, array $args)
 {
     $commandCallable = $command->getCommandCallable();
     if (is_callable($commandCallable)) {
         return $this->callCommand($commandCallable, $args);
     }
     if (!is_string($commandCallable)) {
         throw new \RuntimeException('Callable must be a callable or a container entry for a callable service');
     }
     if (!$this->container->has($commandCallable)) {
         throw new \RuntimeException(sprintf('Container has no entry named: "%s"', $commandCallable));
     }
     $callable = $this->container->get($commandCallable);
     if (!is_callable($callable)) {
         throw new \RuntimeException(sprintf('Container entry: "%s" not callable', $commandCallable));
     }
     $return = $this->callCommand($callable, $args);
     if (is_int($return)) {
         return $return;
     }
     return 0;
 }