Skip to content

Commit

Permalink
fix: switch up mapHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Jun 5, 2023
1 parent 0a14f6b commit ee0630f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/Router.php
Expand Up @@ -107,6 +107,11 @@ public static function match(string $methods, string $pattern, $handler)
'namespace' => null,
];

list($handler, $routeOptions) = static::mapHandler(
$handler,
$routeOptions
);

if (is_string($handler)) {
$namespace = static::$namespace;

Expand All @@ -119,11 +124,6 @@ public static function match(string $methods, string $pattern, $handler)
static::$namespace = $namespace;
}

list($handler, $routeOptions) = static::mapHandler(
$handler,
$routeOptions
);

foreach (explode('|', $methods) as $method) {
static::$routes[$method][] = [
'pattern' => $pattern,
Expand Down
13 changes: 0 additions & 13 deletions src/Router/Core.php
Expand Up @@ -171,19 +171,6 @@ protected static function mapHandler($handler, $options): array
|| is_numeric($key) && is_string($value) && strpos($value, '@')
) {
$handler = $handler[$key];

if (is_string($handler)) {
$namespace = static::$namespace;

if ($options['namespace']) {
static::$namespace = $options['namespace'];
}

$handler = str_replace('\\\\', '\\', static::$namespace . "\\$handler");

static::$namespace = $namespace;
}

unset($handlerData[$key]);
break;
}
Expand Down

0 comments on commit ee0630f

Please sign in to comment.