Exemplo n.º 1
0
 /**
  * Dispatches the command handler.
  * @param string $call The command handler to execute.
  * @return void
  * @throws CommandNotFoundException
  */
 public function dispatch($call = null)
 {
     $command = $this->routes->get($this->arguments->getCommand(1), false);
     if ($this->routes->get($call, false)) {
         $command = $this->routes->get($call, false);
     }
     if ($command) {
         $handler = new ClassMethodHandler($command, $this->arguments);
         return $handler->call($this->arguments);
     }
     throw new CommandNotFoundException(sprintf('Command %s is not registered.', $call));
 }
Exemplo n.º 2
0
 public function testGetItemDefaultValueFromCollection()
 {
     $collection = new Collection([]);
     $collection->push([1 => 'First', 2 => 'Second']);
     $this->assertEquals('Third', $collection->get(3, 'Third'));
 }
Exemplo n.º 3
0
 /**
  * Returns a command from the command index (eg. new or list).
  * @param int $part Will return the Nth command. eg 1 for "./consoleapp new myapp" will return 'new'.
  * @param string $default An optional default value if the command index is not set.
  */
 public function getCommand($part, $default = false)
 {
     return $this->commands->get($part, $default);
 }