Skip to content

Commit

Permalink
update file
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 authored Jun 8, 2024
1 parent 0d7278c commit 258e1fc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libraries/Http/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ private function resolve($callback)

return match (true) {
is_callable($callback) => $this->callCallback($callback), // if it's callable - just execute
is_array($callback) => $this->invokeRouteWithMethodCall(), // If it's an array, assume [ControllerClass, MethodName].
is_string($callback) => $this->invokeRouteWithSingleCallback($callback) //if it's just a Myclass::class
is_array($callback) => $this->invokeRouteWithMethodCall(), // If it's an array, assume [ControllerClass, MethodName].
is_string($callback) => $this->invokeRouteWithSingleCallback($callback) //if it's just a Myclass::class
};
}

Expand Down Expand Up @@ -353,7 +353,7 @@ private function invokeRouteWithMethodCall(): mixed
*/
private function extractRegex(string $method, string $uri)
{
foreach (static::$routeMap[$method] as $route => $handler) {
foreach (static::$routeMap[$method] ?? [] as $route => $handler) {
$pattern = '~^' . $this->compileRoute($route) . '$~';
if (preg_match($pattern, $uri, $params)) {
$params = array_filter($params, 'is_string', ARRAY_FILTER_USE_KEY);
Expand Down Expand Up @@ -414,7 +414,7 @@ public function baseUrl(string $path = '/'): string

return "{$baseUrl}/{$path}";
}

/**
* Renders the error view based on the specified HTTP error code.
*/
Expand Down

0 comments on commit 258e1fc

Please sign in to comment.