Skip to content

Commit c0ba6b5

Browse files
committed
Remove unrelated route method getters
1 parent f79614e commit c0ba6b5

3 files changed

Lines changed: 4 additions & 17 deletions

File tree

src/Http/Route.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,13 @@ public function getHook(): bool
135135
}
136136

137137
/**
138-
* Get alias paths.
138+
* Get additional methods this route is registered under.
139139
*
140140
* @return array<string>
141141
*/
142-
public function getAliasPaths(): array
142+
public function getAdditionalMethods(): array
143143
{
144-
return $this->aliasPaths;
145-
}
146-
147-
/**
148-
* Get methods this route is registered under.
149-
*
150-
* @return array<string>
151-
*/
152-
public function getMethods(): array
153-
{
154-
return array_merge([$this->method], $this->additionalMethods);
144+
return $this->additionalMethods;
155145
}
156146

157147
/**

src/Http/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static function addRoute(Route $route): void
8989

9090
self::$routes[$route->getMethod()][$path] = $route;
9191

92-
foreach (\array_slice($route->getMethods(), 1) as $method) {
92+
foreach ($route->getAdditionalMethods() as $method) {
9393
self::addRouteMethod($method, $route);
9494
}
9595
}

tests/RouterTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ public function testCanMatchRouteWithMultipleMethods(): void
151151
$this->assertNull(Router::match(Http::REQUEST_METHOD_PUT, '/userinfo'));
152152

153153
$this->assertSame(Http::REQUEST_METHOD_GET, $route->getMethod());
154-
$this->assertSame([Http::REQUEST_METHOD_GET, Http::REQUEST_METHOD_POST], $route->getMethods());
155154
}
156155

157156
public function testCanMatchRouteWithStringMethod(): void
@@ -160,7 +159,6 @@ public function testCanMatchRouteWithStringMethod(): void
160159

161160
$this->assertEquals($route, Router::match(Http::REQUEST_METHOD_GET, '/userinfo')?->route);
162161
$this->assertNull(Router::match(Http::REQUEST_METHOD_POST, '/userinfo'));
163-
$this->assertSame([Http::REQUEST_METHOD_GET], $route->getMethods());
164162
}
165163

166164
public function testCanMatchRouteWithMultipleMethodsAndPlaceholder(): void
@@ -209,7 +207,6 @@ public function testCanOverrideRouteMethod(): void
209207
], '/userinfo');
210208

211209
$this->assertEquals($routeGET, Router::match(Http::REQUEST_METHOD_POST, '/userinfo')?->route);
212-
$this->assertSame([Http::REQUEST_METHOD_GET, Http::REQUEST_METHOD_POST], $routeGET->getMethods());
213210
} finally {
214211
Router::setAllowOverride(false);
215212
}

0 commit comments

Comments
 (0)