Skip to content

Commit

Permalink
refactor: rename method name
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jun 21, 2024
1 parent ea5a585 commit 497b499
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions system/Router/AutoRouterImproved.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private function searchFirstController(): bool
$segment = array_shift($segments);
$controllerPos++;

$class = $this->translateURIDashes($segment);
$class = $this->translateURI($segment);

// as soon as we encounter any segment that is not PSR-4 compliant, stop searching
if (! $this->isValidSegment($class)) {
Expand Down Expand Up @@ -209,7 +209,7 @@ private function searchLastDefaultController(): bool
}

$namespaces = array_map(
fn ($segment) => $this->translateURIDashes($segment),
fn ($segment) => $this->translateURI($segment),
$segments
);

Expand Down Expand Up @@ -307,7 +307,7 @@ public function getRoute(string $uri, string $httpVerb): array

$method = '';
if ($methodParam !== null) {
$method = $httpVerb . $this->translateURIDashes($methodParam);
$method = $httpVerb . $this->translateURI($methodParam);

$this->checkUriForMethod($method);
}
Expand Down Expand Up @@ -544,7 +544,10 @@ private function isValidSegment(string $segment): bool
return (bool) preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $segment);
}

private function translateURIDashes(string $segment): string
/**
* Translates URI segment to CamelCase or replaces `-` with `_`.
*/
private function translateURI(string $segment): string
{
if ($this->translateUriToCamelCase) {
if (strtolower($segment) !== $segment) {
Expand Down

0 comments on commit 497b499

Please sign in to comment.