public function __construct($name, $version, $routes, Console $console = null, DispatcherInterface $dispatcher = null)
{
if (!is_array($routes) && !$routes instanceof Traversable) {
throw new InvalidArgumentException('Routes must be provided as an array or Traversable object');
}
$this->name = $name;
$this->version = $version;
if (null === $console) {
$console = DefaultConsole::getInstance();
}
$this->console = $console;
if (null === $dispatcher) {
$dispatcher = new Dispatcher();
}
$this->dispatcher = $dispatcher;
$this->routeCollection = $routeCollection = new RouteCollection();
$this->setRoutes($routes);
$this->banner = [$this, 'showVersion'];
if (!$routeCollection->hasRoute('help')) {
$this->setupHelpCommand($routeCollection, $dispatcher);
}
if (!$routeCollection->hasRoute('version')) {
$this->setupVersionCommand($routeCollection, $dispatcher);
}
if (!$routeCollection->hasRoute('autocomplete')) {
$this->setupAutocompleteCommand($routeCollection, $dispatcher);
}
}