*
* @throws HTTPException\InternalServerErrorException In case of invalid configs
*/
- public function loadRoutes(array $routes)
+ public function loadRoutes(array $routes): Router
{
$routeCollector = ($this->routeCollector ?? new RouteCollector(new Std(), new GroupCountBased()));
return $this;
}
+ /**
+ * Adds multiple routes to a route collector
+ *
+ * @param RouteCollector $routeCollector Route collector instance
+ * @param array $routes Multiple routes to be added
+ * @throws HTTPException\InternalServerErrorException If route was wrong (somehow)
+ */
private function addRoutes(RouteCollector $routeCollector, array $routes)
{
foreach ($routes as $route => $config) {
*
* @return bool
*/
- private function isRoute(array $config)
+ private function isRoute(array $config): bool
{
return
// The config array should at least have one entry
* @throws HTTPException\MethodNotAllowedException If a rule matched but the method didn't
* @throws HTTPException\NotFoundException If no rule matched
*/
- private function getModuleClass()
+ private function getModuleClass(): string
{
$cmd = $this->args->getCommand();
$cmd = '/' . ltrim($cmd, '/');
$this->parameters = [];
- // Check if the HTTP method ist OPTIONS and return the special Options Module with the possible HTTP methods
+ // Check if the HTTP method is OPTIONS and return the special Options Module with the possible HTTP methods
if ($this->args->getMethod() === static::OPTIONS) {
- $routeOptions = $dispatcher->getOptions($cmd);
-
$moduleClass = Options::class;
- $this->parameters = ['allowedMethods' => $routeOptions];
+ $this->parameters = ['allowedMethods' => $dispatcher->getOptions($cmd)];
} else {
$routeInfo = $dispatcher->dispatch($this->args->getMethod(), $cmd);
if ($routeInfo[0] === Dispatcher::FOUND) {