Skip to content

Commit aeafd03

Browse files
authored
Merge pull request #8621 from justbyitself/refactor-1
refactor: apply early return pattern
2 parents 58aa732 + 647d20b commit aeafd03

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

system/Commands/Utilities/Routes/ControllerMethodReader.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,17 @@ private function getRouteWithoutController(
159159
string $classname,
160160
string $methodName
161161
): array {
162-
$output = [];
163-
164-
if ($classShortname === $defaultController) {
165-
$pattern = '#' . preg_quote(lcfirst($defaultController), '#') . '\z#';
166-
$routeWithoutController = rtrim(preg_replace($pattern, '', $uriByClass), '/');
167-
$routeWithoutController = $routeWithoutController ?: '/';
168-
169-
$output[] = [
170-
'route' => $routeWithoutController,
171-
'handler' => '\\' . $classname . '::' . $methodName,
172-
];
162+
if ($classShortname !== $defaultController) {
163+
return [];
173164
}
174165

175-
return $output;
166+
$pattern = '#' . preg_quote(lcfirst($defaultController), '#') . '\z#';
167+
$routeWithoutController = rtrim(preg_replace($pattern, '', $uriByClass), '/');
168+
$routeWithoutController = $routeWithoutController ?: '/';
169+
170+
return [[
171+
'route' => $routeWithoutController,
172+
'handler' => '\\' . $classname . '::' . $methodName,
173+
]];
176174
}
177175
}

0 commit comments

Comments
 (0)