RouteResult
The immutable, never-null outcome of {@see RouterInterface::match()} — and the only value routing injects into the request. A success carries the matched {@see Route} plus the extracted path arguments; a method failure carries the verbs the path does allow (for the `Allow` header); a miss carries nothing. Built only through the three named constructors, so illegal states (a match with no route, a 405 with no verbs) are unrepresentable.
RouteResult::matched()
public static function matched(Milpa\Http\Routing\Route $route, array $parameters = []): selfA successful match: the route and its extracted path arguments.
Parameters
| Name | Type | Description |
|---|---|---|
| $route | Milpa\Http\Routing\Route | |
| $parameters | array<string, string> |
RouteResult::notFound()
public static function notFound(): selfNo route matched the path (→ 404).
RouteResult::methodNotAllowed()
public static function methodNotAllowed(array $allowedMethods): selfThe path matched but the method did not (→ 405); carries the allowed verbs.
Parameters
| Name | Type | Description |
|---|---|---|
| $allowedMethods | non-empty-list<HttpMethod> |
RouteResult::isMatched()
public function isMatched(): boolWhether a route was matched.
RouteResult::parameter()
public function parameter(string $name, ?string $default = null): ?stringRead a single extracted path parameter, or the default when it is absent.
Parameters
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $default | ?string |