Repository navigation
Internals Router Http HttpMethod
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/router/http/HttpMethod.php · Snapshot 8411f4287706.
Routing separates definition, HTTP request snapshot, matching, method policy, execution and error responses. Collaborators can be replaced through constructor injection.
final class HttpMethod implements \router\interface\IMethodPolicyNo own constants, enum cases, traits or property declarations. Inherited members are documented on the parent reference page.
| Method | Signature |
|---|---|
| normalize | public function normalize(string $method): string |
| isSafe | public function isSafe(string $method): bool |
| allows | public function allows(string $routeMethod, string $requestMethod): bool |
| allowed | public function allowed(string $routeMethod): array |
public function normalize(string $method): string| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$method |
string $method |
HTTP method token; validation/normalization follows the method policy. |
Return expressions (including local callbacks): $method.
Explicit exceptions: \InvalidArgumentException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
Implementation, validation guards and interaction order
public function normalize(string $method): string
{
$method = strtoupper(trim($method));
if (!preg_match('/^[A-Z]+$/D', $method)) {
throw new \InvalidArgumentException('Invalid HTTP method.');
}
return $method;
}public function isSafe(string $method): bool| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$method |
string $method |
HTTP method token; validation/normalization follows the method policy. |
Return expressions (including local callbacks): in_array(strtoupper($method), ['GET', 'HEAD', 'OPTIONS'], true).
Implementation, validation guards and interaction order
public function isSafe(string $method): bool
{
return in_array(strtoupper($method), ['GET', 'HEAD', 'OPTIONS'], true);
}public function allows(string $routeMethod, string $requestMethod): bool| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$routeMethod |
string $routeMethod |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$requestMethod |
string $requestMethod |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): $routeMethod === $requestMethod || ($routeMethod === 'GET' && $requestMethod === 'HEAD').
Implementation, validation guards and interaction order
public function allows(string $routeMethod, string $requestMethod): bool
{
return $routeMethod === $requestMethod || ($routeMethod === 'GET' && $requestMethod === 'HEAD');
}public function allowed(string $routeMethod): array| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$routeMethod |
string $routeMethod |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): $routeMethod === 'GET' ? ['GET', 'HEAD'] : [$routeMethod].
Implementation, validation guards and interaction order
public function allowed(string $routeMethod): array
{
return $routeMethod === 'GET' ? ['GET', 'HEAD'] : [$routeMethod];
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes