/** * Add route * * @param Route|array $route Route * * @return $this * @throws \LogicException */ public function addRoute($route) { if (!$route instanceof Route) { $route = Route::objectify($route); } $name = $route->getName(); if (isset($this->routes[$name])) { throw new \LogicException(sprintf("Route name '%s' is already used.", $name)); } $this->routes[$name] = $route; $alias = $route->getAlias(); if ($alias !== null) { if (isset($this->routes[$alias])) { throw new \LogicException(sprintf("Route alias '%s' is already used.", $alias)); } $this->routes[$alias] =& $this->routes[$name]; } return $this; }