@@ -19,7 +19,7 @@ |
||
19 | 19 | class ForbiddenException extends HttpExceptionAbstract |
20 | 20 | { |
21 | 21 | |
22 | - protected $code = 403; |
|
23 | - protected $message = "Forbidden"; |
|
22 | + protected $code = 403; |
|
23 | + protected $message = "Forbidden"; |
|
24 | 24 | |
25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class GoneException extends HttpExceptionAbstract |
20 | 20 | { |
21 | 21 | |
22 | - protected $code = 410; |
|
23 | - protected $message = "Gone"; |
|
22 | + protected $code = 410; |
|
23 | + protected $message = "Gone"; |
|
24 | 24 | |
25 | 25 | } |
@@ -22,20 +22,20 @@ |
||
22 | 22 | abstract class HttpExceptionAbstract extends Exception |
23 | 23 | { |
24 | 24 | |
25 | - public function getResponse(ResponseInterface $response) |
|
26 | - { |
|
27 | - return $response->withStatus($this->code, $this->message); |
|
28 | - } |
|
25 | + public function getResponse(ResponseInterface $response) |
|
26 | + { |
|
27 | + return $response->withStatus($this->code, $this->message); |
|
28 | + } |
|
29 | 29 | |
30 | - public function getJsonResponse(ResponseInterface $response) |
|
31 | - { |
|
32 | - $response->withAddedHeader("content-type", "application/json"); |
|
30 | + public function getJsonResponse(ResponseInterface $response) |
|
31 | + { |
|
32 | + $response->withAddedHeader("content-type", "application/json"); |
|
33 | 33 | |
34 | - if ($response->getBody()->isWritable()) { |
|
35 | - $response->getBody()->write(json_encode(["status-code" => $this->code, "reason-phrase" => $this->message])); |
|
36 | - } |
|
34 | + if ($response->getBody()->isWritable()) { |
|
35 | + $response->getBody()->write(json_encode(["status-code" => $this->code, "reason-phrase" => $this->message])); |
|
36 | + } |
|
37 | 37 | |
38 | - return $this->getResponse($response); |
|
39 | - } |
|
38 | + return $this->getResponse($response); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class LengthRequiredException extends HttpExceptionAbstract |
20 | 20 | { |
21 | 21 | |
22 | - protected $code = 411; |
|
23 | - protected $message = "Length Required"; |
|
22 | + protected $code = 411; |
|
23 | + protected $message = "Length Required"; |
|
24 | 24 | |
25 | 25 | } |
@@ -19,64 +19,64 @@ |
||
19 | 19 | class MethodNotAllowedException extends HttpExceptionAbstract |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - |
|
26 | - protected $requestedMethod; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - |
|
32 | - protected $requestedUri; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string[] |
|
36 | - */ |
|
37 | - |
|
38 | - protected $allowedMethods; |
|
39 | - |
|
40 | - /** |
|
41 | - * MethodNotAllowedException constructor. |
|
42 | - * |
|
43 | - * @param string $requestedMethod |
|
44 | - * @param string $requestedUri |
|
45 | - * @param string[] $allowedMethods |
|
46 | - */ |
|
47 | - |
|
48 | - public function __construct($requestedMethod, $requestedUri, array $allowedMethods) |
|
49 | - { |
|
50 | - $this->requestedMethod = $requestedMethod; |
|
51 | - $this->requestedUri = $requestedUri; |
|
52 | - $this->allowedMethods = $allowedMethods; |
|
53 | - $this->code = 405; |
|
54 | - $this->message = "Method Not Allowed"; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Verify if the given HTTP method is allowed for the request. |
|
59 | - * |
|
60 | - * @param string $method An HTTP method |
|
61 | - * @return bool |
|
62 | - */ |
|
63 | - |
|
64 | - public function can($method) |
|
65 | - { |
|
66 | - return in_array(strtolower($method), $this->allowedMethods); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * The HTTP specification requires that a 405 Method Not Allowed response include the |
|
71 | - * Allow: header to detail available methods for the requested resource. |
|
72 | - * |
|
73 | - * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html section 14.7 |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - |
|
77 | - public function allowed() |
|
78 | - { |
|
79 | - return implode(', ', $this->allowedMethods); |
|
80 | - } |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + |
|
26 | + protected $requestedMethod; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + |
|
32 | + protected $requestedUri; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string[] |
|
36 | + */ |
|
37 | + |
|
38 | + protected $allowedMethods; |
|
39 | + |
|
40 | + /** |
|
41 | + * MethodNotAllowedException constructor. |
|
42 | + * |
|
43 | + * @param string $requestedMethod |
|
44 | + * @param string $requestedUri |
|
45 | + * @param string[] $allowedMethods |
|
46 | + */ |
|
47 | + |
|
48 | + public function __construct($requestedMethod, $requestedUri, array $allowedMethods) |
|
49 | + { |
|
50 | + $this->requestedMethod = $requestedMethod; |
|
51 | + $this->requestedUri = $requestedUri; |
|
52 | + $this->allowedMethods = $allowedMethods; |
|
53 | + $this->code = 405; |
|
54 | + $this->message = "Method Not Allowed"; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Verify if the given HTTP method is allowed for the request. |
|
59 | + * |
|
60 | + * @param string $method An HTTP method |
|
61 | + * @return bool |
|
62 | + */ |
|
63 | + |
|
64 | + public function can($method) |
|
65 | + { |
|
66 | + return in_array(strtolower($method), $this->allowedMethods); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * The HTTP specification requires that a 405 Method Not Allowed response include the |
|
71 | + * Allow: header to detail available methods for the requested resource. |
|
72 | + * |
|
73 | + * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html section 14.7 |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + |
|
77 | + public function allowed() |
|
78 | + { |
|
79 | + return implode(', ', $this->allowedMethods); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class NotAcceptableException extends HttpExceptionAbstract |
20 | 20 | { |
21 | 21 | |
22 | - protected $code = 406; |
|
23 | - protected $message = "Not Acceptable"; |
|
22 | + protected $code = 406; |
|
23 | + protected $message = "Not Acceptable"; |
|
24 | 24 | |
25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class NotFoundException extends HttpExceptionAbstract |
20 | 20 | { |
21 | 21 | |
22 | - protected $code = 404; |
|
23 | - protected $message = "Not Found"; |
|
22 | + protected $code = 404; |
|
23 | + protected $message = "Not Found"; |
|
24 | 24 | |
25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class PaymentRequiredException extends HttpExceptionAbstract |
20 | 20 | { |
21 | 21 | |
22 | - protected $code = 402; |
|
23 | - protected $message = "Payment Required"; |
|
22 | + protected $code = 402; |
|
23 | + protected $message = "Payment Required"; |
|
24 | 24 | |
25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class PreconditionFailedException extends HttpExceptionAbstract |
20 | 20 | { |
21 | 21 | |
22 | - protected $code = 412; |
|
23 | - protected $message = "Precondition Failed"; |
|
22 | + protected $code = 412; |
|
23 | + protected $message = "Precondition Failed"; |
|
24 | 24 | |
25 | 25 | } |