Esempio n. 1
0
 /**
  * @param Input $input
  *
  * @return int
  *
  * @throws UnknownCommandException              If the command is not found
  * @throws Exception\UndefinedArgumentException If the argument is undefined
  *
  * @api
  */
 public function run(Input $input)
 {
     $commandName = $input->getCommandName();
     if (!isset($this->commands[$commandName])) {
         throw new UnknownCommandException($input, $this->commands);
     }
     $command = $this->commands[$commandName];
     return $command->execute($input);
 }
Esempio n. 2
0
 function it_handles_priorities(InputConstraint $highPriority, InputConstraint $middlePriority, InputConstraint $lowPriority, Input $input)
 {
     $this->addConstraint($lowPriority, self::LOW_PRIORITY);
     $this->addConstraint($highPriority, self::HIGH_PRIORITY);
     $this->addConstraint($middlePriority, self::MIDDLE_PRIORITY);
     $invalidInputException = new InvalidInputException($input->getWrappedObject(), self::MESSAGE);
     $highPriority->throwIfInvalid($input)->shouldBeCalled();
     $middlePriority->throwIfInvalid($input)->willThrow($invalidInputException);
     $lowPriority->throwIfInvalid($input)->shouldNotBeCalled();
     $this->shouldThrow($invalidInputException)->duringThrowIfInvalid($input);
 }
Esempio n. 3
0
 /**
  * @param Input $input
  * @param array $commands
  *
  * @api
  */
 public function __construct(Input $input, array $commands)
 {
     $this->input = $input;
     $this->commands = $commands;
     parent::__construct(sprintf('Unknown command: "%s"', $input->getCommandName()));
 }