routes[] = $route; return $route; } /** * Get (first) Route matching url and filters * * @param string $url * @param array $filters * @return Route|null */ public function run(string $url, array $filters):?Route{ foreach($this->routes as $route){ if($route->match($url, $filters)) return $route; } return null; } /** * Get (first) Route by name * * @param string $name * @return Route|null */ public function get(string $name):?Route{ foreach($this->routes as $route){ if($route->matchName($name)) return $route; } return null; } /** * Redirect helper * * @param string $url * @param bool $stop * @return void */ public static function redirect(string $url, bool $stop = true){ header('Location: '.$url); if($stop) exit(); } }