/** * 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)); }
public function testGetItemDefaultValueFromCollection() { $collection = new Collection([]); $collection->push([1 => 'First', 2 => 'Second']); $this->assertEquals('Third', $collection->get(3, 'Third')); }
/** * 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); }