@@ -24,37 +24,37 @@ |
||
| 24 | 24 | abstract class EnhancerAbstractStrategy implements StrategyInterface |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Key used to store the real route strategy on metadata. |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - |
|
| 33 | - protected $metadataStrategyKey = "strategy"; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @inheritdoc |
|
| 37 | - * @throws BadRouteException |
|
| 38 | - */ |
|
| 39 | - |
|
| 40 | - public function call(Route $route) |
|
| 41 | - { |
|
| 42 | - if ($route->hasMetadata($this->metadataStrategyKey)) { |
|
| 43 | - $route->setStrategy($route->getMetadata($this->metadataStrategyKey)); |
|
| 44 | - } else $route->setStrategy(null); |
|
| 45 | - |
|
| 46 | - $this->enhance($route); |
|
| 47 | - |
|
| 48 | - return $route->call(); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Manipulate route object before the dispatch. |
|
| 53 | - * |
|
| 54 | - * @param Route $route |
|
| 55 | - * @return mixed |
|
| 56 | - */ |
|
| 57 | - |
|
| 58 | - abstract public function enhance(Route $route); |
|
| 27 | + /** |
|
| 28 | + * Key used to store the real route strategy on metadata. |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + |
|
| 33 | + protected $metadataStrategyKey = "strategy"; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @inheritdoc |
|
| 37 | + * @throws BadRouteException |
|
| 38 | + */ |
|
| 39 | + |
|
| 40 | + public function call(Route $route) |
|
| 41 | + { |
|
| 42 | + if ($route->hasMetadata($this->metadataStrategyKey)) { |
|
| 43 | + $route->setStrategy($route->getMetadata($this->metadataStrategyKey)); |
|
| 44 | + } else $route->setStrategy(null); |
|
| 45 | + |
|
| 46 | + $this->enhance($route); |
|
| 47 | + |
|
| 48 | + return $route->call(); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Manipulate route object before the dispatch. |
|
| 53 | + * |
|
| 54 | + * @param Route $route |
|
| 55 | + * @return mixed |
|
| 56 | + */ |
|
| 57 | + |
|
| 58 | + abstract public function enhance(Route $route); |
|
| 59 | 59 | |
| 60 | 60 | } |
@@ -20,16 +20,16 @@ |
||
| 20 | 20 | interface MatcherAwareInterface |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @param \Codeburner\Router\Matcher $matcher |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @param \Codeburner\Router\Matcher $matcher |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - public function setMatcher(\Codeburner\Router\Matcher $matcher); |
|
| 27 | + public function setMatcher(\Codeburner\Router\Matcher $matcher); |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @return \Codeburner\Router\Matcher |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @return \Codeburner\Router\Matcher |
|
| 31 | + */ |
|
| 32 | 32 | |
| 33 | - public function getMatcher(); |
|
| 33 | + public function getMatcher(); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -19,13 +19,13 @@ |
||
| 19 | 19 | interface StrategyInterface |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Dispatch the matched route action. |
|
| 24 | - * |
|
| 25 | - * @param \Codeburner\Router\Route $route |
|
| 26 | - * @return mixed The response of request. |
|
| 27 | - */ |
|
| 22 | + /** |
|
| 23 | + * Dispatch the matched route action. |
|
| 24 | + * |
|
| 25 | + * @param \Codeburner\Router\Route $route |
|
| 26 | + * @return mixed The response of request. |
|
| 27 | + */ |
|
| 28 | 28 | |
| 29 | - public function call(\Codeburner\Router\Route $route); |
|
| 29 | + public function call(\Codeburner\Router\Route $route); |
|
| 30 | 30 | |
| 31 | 31 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class BadRequestException extends HttpExceptionAbstract |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - protected $code = 400; |
|
| 23 | - protected $message = "Bad Request"; |
|
| 22 | + protected $code = 400; |
|
| 23 | + protected $message = "Bad Request"; |
|
| 24 | 24 | |
| 25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class ConflictException extends HttpExceptionAbstract |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - protected $code = 409; |
|
| 23 | - protected $message = "Conflict"; |
|
| 22 | + protected $code = 409; |
|
| 23 | + protected $message = "Conflict"; |
|
| 24 | 24 | |
| 25 | 25 | } |
@@ -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 | } |