We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
RouteNameExtender.php
1 parent 842bd87 commit a593d72Copy full SHA for a593d72
tests/Extenders/RouteNameExtender.php
@@ -7,12 +7,20 @@
7
use DragonCode\LaravelRouteNames\Routing\Route;
8
use Illuminate\Support\Str;
9
10
-final class RouteNameExtender
+class RouteNameExtender
11
{
12
public function __invoke(string $name, Route $route): string
13
14
- return Str::of($route->uri())->startsWith('api/v1')
15
- ? Str::replaceFirst('api.v1', 'api.v2', $name)
16
- : $name;
+ return $this->has($route->uri()) ? $this->replace($name) : $name;
+ }
+
17
+ protected function has(string $uri): bool
18
+ {
19
+ return Str::of($uri)->startsWith('api/v1');
20
21
22
+ protected function replace(string $name): string
23
24
+ return Str::replaceFirst('api.v1', 'api.v2', $name);
25
}
26
0 commit comments