Thrown when a route is matched but uses an invalid HTTP method. The user
should return a 405 Method Not Allowed
error response.
class MethodNotAllowedException extends Exception implements RouterException
{
// Properties
protected string $message
protected int $code
protected string $file
protected int $line
// Methods
public function __construct(array $allowed, string $actual, int $code = 0, Throwable $previous = null)
public function __toString(): string
final private function __clone()
final public function getAllowed(): array
final public function getCode()
final public function getFile(): string
final public function getLine(): int
final public function getMessage(): string
final public function getPrevious(): Throwable
final public function getTrace(): array
final public function getTraceAsString(): string
}
Extends Exception.
Implements RouterException.
Note: a
405
response is required to include anAllow:
header listing valid methods for the requested URL. You can use thegetAllowed()
method.
- __construct
- __toString
- __clone
- getAllowed
- getCode
- getFile
- getLine
- getMessage
- getPrevious
- getTrace
- getTraceAsString
Builds a MethodNotAllowedException
instance.
__construct(array $allowed, string $actual, int $code = 0, Throwable $previous = null)
-
string[]
$allowedRequired. Array of allowed HTTP methods to be returned by
getAllowed()
. -
string
$actualRequired. The actual HTTP method. Used to generate the message returned by
getMessage()
. -
int
$codeThe Exception code.
-
Throwable
$previousThe previous exception used for the exception chaining.
Nothing is thrown.
MethodNotAllowedException
Gets a list of allowed HTTP methods.
getAllowed(): array
None.
Nothing is thrown.
-
string[]
Allowed HTTP methods.