1 | <?php |
||
20 | class MethodNotAllowedException extends BadRouteException |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * The HTTP method from request. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | |||
29 | public $requestedMethod; |
||
30 | |||
31 | /** |
||
32 | * The requested URi. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | |||
37 | public $requestedUri; |
||
38 | |||
39 | /** |
||
40 | * All the allowed HTTP methods and routes for the request. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | |||
45 | public $allowedMethods; |
||
46 | |||
47 | /** |
||
48 | * Exception constructor. |
||
49 | * |
||
50 | * @param string $requestedMethod The request HTTP method. |
||
51 | * @param string $requestedUri The request URi. |
||
52 | * @param array $allowedMethods All the allowed HTTP methods and routes for the request. |
||
53 | * @param string $message The exception error message. |
||
54 | * @param integer $code The exception error code. |
||
55 | */ |
||
56 | |||
57 | 5 | public function __construct($requestedMethod, $requestedUri, array $allowedMethods, $message = null, $code = 405) |
|
64 | |||
65 | /** |
||
66 | * Verify if the given HTTP method is allowed for the request. |
||
67 | * |
||
68 | * @param string $method An HTTP method |
||
69 | * @return bool |
||
70 | */ |
||
71 | |||
72 | 1 | public function can($method) |
|
76 | |||
77 | /** |
||
78 | * The HTTP specification requires that a 405 Method Not Allowed response include the |
||
79 | * Allow: header to detail available methods for the requested resource. |
||
80 | * |
||
81 | * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html section 14.7 |
||
82 | * @return string |
||
83 | */ |
||
84 | |||
85 | 1 | public function allowed() |
|
89 | |||
90 | } |
||
91 |