@@ -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 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class RequestTimeOutException extends HttpExceptionAbstract |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - protected $code = 408; |
|
| 23 | - protected $message = "Request Time Out"; |
|
| 22 | + protected $code = 408; |
|
| 23 | + protected $message = "Request Time Out"; |
|
| 24 | 24 | |
| 25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class ServiceUnavailableException extends HttpExceptionAbstract |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - protected $code = 503; |
|
| 23 | - protected $message = "Service Unavailable"; |
|
| 22 | + protected $code = 503; |
|
| 23 | + protected $message = "Service Unavailable"; |
|
| 24 | 24 | |
| 25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class UnauthorizedException extends HttpExceptionAbstract |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - protected $code = 401; |
|
| 23 | - protected $message = "Unauthorized Exception"; |
|
| 22 | + protected $code = 401; |
|
| 23 | + protected $message = "Unauthorized Exception"; |
|
| 24 | 24 | |
| 25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class UnsupportedMediaTypeException extends HttpExceptionAbstract |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - protected $code = 415; |
|
| 23 | - protected $message = "Unsupported Media Type"; |
|
| 22 | + protected $code = 415; |
|
| 23 | + protected $message = "Unsupported Media Type"; |
|
| 24 | 24 | |
| 25 | 25 | } |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | class MethodNotSupportedException extends \Exception |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - public function __construct($method) { |
|
| 23 | - $this->message = "The HTTP method '$method' is not supported by the route collector."; |
|
| 24 | - } |
|
| 22 | + public function __construct($method) { |
|
| 23 | + $this->message = "The HTTP method '$method' is not supported by the route collector."; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | } |
@@ -22,69 +22,69 @@ |
||
| 22 | 22 | trait RequestAwareTrait |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var RequestInterface |
|
| 27 | - */ |
|
| 28 | - |
|
| 29 | - protected $request; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var ResponseInterface |
|
| 33 | - */ |
|
| 34 | - |
|
| 35 | - protected $response; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * RequestResponseStrategy constructor. |
|
| 39 | - * |
|
| 40 | - * @param RequestInterface $request |
|
| 41 | - * @param ResponseInterface $response |
|
| 42 | - */ |
|
| 43 | - |
|
| 44 | - public function __construct(RequestInterface $request, ResponseInterface $response) |
|
| 45 | - { |
|
| 46 | - $this->request = $request; |
|
| 47 | - $this->response = $response; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @return RequestInterface |
|
| 52 | - */ |
|
| 53 | - |
|
| 54 | - public function getRequest() |
|
| 55 | - { |
|
| 56 | - return $this->request; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @param RequestInterface $request |
|
| 61 | - * @return self |
|
| 62 | - */ |
|
| 63 | - |
|
| 64 | - public function setRequest(RequestInterface $request) |
|
| 65 | - { |
|
| 66 | - $this->request = $request; |
|
| 67 | - return $this; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return ResponseInterface |
|
| 72 | - */ |
|
| 73 | - |
|
| 74 | - public function getResponse() |
|
| 75 | - { |
|
| 76 | - return $this->response; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @param ResponseInterface $response |
|
| 81 | - * @return self |
|
| 82 | - */ |
|
| 83 | - |
|
| 84 | - public function setResponse(ResponseInterface $response) |
|
| 85 | - { |
|
| 86 | - $this->response = $response; |
|
| 87 | - return $this; |
|
| 88 | - } |
|
| 25 | + /** |
|
| 26 | + * @var RequestInterface |
|
| 27 | + */ |
|
| 28 | + |
|
| 29 | + protected $request; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var ResponseInterface |
|
| 33 | + */ |
|
| 34 | + |
|
| 35 | + protected $response; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * RequestResponseStrategy constructor. |
|
| 39 | + * |
|
| 40 | + * @param RequestInterface $request |
|
| 41 | + * @param ResponseInterface $response |
|
| 42 | + */ |
|
| 43 | + |
|
| 44 | + public function __construct(RequestInterface $request, ResponseInterface $response) |
|
| 45 | + { |
|
| 46 | + $this->request = $request; |
|
| 47 | + $this->response = $response; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @return RequestInterface |
|
| 52 | + */ |
|
| 53 | + |
|
| 54 | + public function getRequest() |
|
| 55 | + { |
|
| 56 | + return $this->request; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @param RequestInterface $request |
|
| 61 | + * @return self |
|
| 62 | + */ |
|
| 63 | + |
|
| 64 | + public function setRequest(RequestInterface $request) |
|
| 65 | + { |
|
| 66 | + $this->request = $request; |
|
| 67 | + return $this; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return ResponseInterface |
|
| 72 | + */ |
|
| 73 | + |
|
| 74 | + public function getResponse() |
|
| 75 | + { |
|
| 76 | + return $this->response; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param ResponseInterface $response |
|
| 81 | + * @return self |
|
| 82 | + */ |
|
| 83 | + |
|
| 84 | + public function setResponse(ResponseInterface $response) |
|
| 85 | + { |
|
| 86 | + $this->response = $response; |
|
| 87 | + return $this; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | } |
@@ -25,32 +25,32 @@ |
||
| 25 | 25 | class RequestJsonStrategy implements StrategyInterface |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - use RequestAwareTrait; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @inheritdoc |
|
| 32 | - * @throws RuntimeException |
|
| 33 | - * @return ResponseInterface |
|
| 34 | - */ |
|
| 35 | - |
|
| 36 | - public function call(Route $route) |
|
| 37 | - { |
|
| 38 | - try { |
|
| 39 | - $response = call_user_func($route->getAction(), $this->request, $route->getMergedParams()); |
|
| 40 | - |
|
| 41 | - if (is_array($response)) { |
|
| 42 | - $this->response->getBody()->write(json_encode($response)); |
|
| 43 | - $response = $this->response; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if ($response instanceof ResponseInterface) { |
|
| 47 | - return $response->withAddedHeader("content-type", "application/json"); |
|
| 48 | - } |
|
| 49 | - } catch (HttpExceptionAbstract $e) { |
|
| 50 | - return $e->getJsonResponse($this->response); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - throw new RuntimeException("Unable to determine a json response from action returned value."); |
|
| 54 | - } |
|
| 28 | + use RequestAwareTrait; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @inheritdoc |
|
| 32 | + * @throws RuntimeException |
|
| 33 | + * @return ResponseInterface |
|
| 34 | + */ |
|
| 35 | + |
|
| 36 | + public function call(Route $route) |
|
| 37 | + { |
|
| 38 | + try { |
|
| 39 | + $response = call_user_func($route->getAction(), $this->request, $route->getMergedParams()); |
|
| 40 | + |
|
| 41 | + if (is_array($response)) { |
|
| 42 | + $this->response->getBody()->write(json_encode($response)); |
|
| 43 | + $response = $this->response; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if ($response instanceof ResponseInterface) { |
|
| 47 | + return $response->withAddedHeader("content-type", "application/json"); |
|
| 48 | + } |
|
| 49 | + } catch (HttpExceptionAbstract $e) { |
|
| 50 | + return $e->getJsonResponse($this->response); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + throw new RuntimeException("Unable to determine a json response from action returned value."); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | } |