@@ -49,7 +49,7 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | protected function getParams(Route $route): array |
| 51 | 51 | { |
| 52 | - return array_filter($route->getMatchesParams(), function ($name) { |
|
| 52 | + return array_filter($route->getMatchesParams(), function($name) { |
|
| 53 | 53 | return $name[0] !== '_'; |
| 54 | 54 | }, ARRAY_FILTER_USE_KEY); |
| 55 | 55 | } |
@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class EndPoint implements RequestHandlerInterface |
| 12 | 12 | { |
| 13 | - /** @var string|null */ |
|
| 14 | - protected $controller; |
|
| 15 | - /** @var string|null */ |
|
| 16 | - protected $action; |
|
| 13 | + /** @var string|null */ |
|
| 14 | + protected $controller; |
|
| 15 | + /** @var string|null */ |
|
| 16 | + protected $action; |
|
| 17 | 17 | |
| 18 | 18 | public function __construct(array $params = []) |
| 19 | 19 | { |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | * @throws \BadMethodCallException |
| 32 | 32 | */ |
| 33 | 33 | public function handle(ServerRequestInterface $request): ResponseInterface |
| 34 | - { |
|
| 35 | - $route = $this->getRoute($request); |
|
| 34 | + { |
|
| 35 | + $route = $this->getRoute($request); |
|
| 36 | 36 | $endPoint = $this->getPoint($request); |
| 37 | 37 | |
| 38 | 38 | $params = $this->getParams($route); |
@@ -44,18 +44,18 @@ discard block |
||
| 44 | 44 | $this->{$name} = $value; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Get params from router and remove all protected params (_controller/_action/_other) |
|
| 49 | - * |
|
| 50 | - * @param Route $route |
|
| 51 | - * @return array |
|
| 52 | - */ |
|
| 47 | + /** |
|
| 48 | + * Get params from router and remove all protected params (_controller/_action/_other) |
|
| 49 | + * |
|
| 50 | + * @param Route $route |
|
| 51 | + * @return array |
|
| 52 | + */ |
|
| 53 | 53 | protected function getParams(Route $route): array |
| 54 | - { |
|
| 54 | + { |
|
| 55 | 55 | return array_filter($route->getMatchesParams(), function ($name) { |
| 56 | 56 | return $name[0] !== '_'; |
| 57 | 57 | }, ARRAY_FILTER_USE_KEY); |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @param ServerRequestInterface $request |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @return callable |
| 64 | 64 | * @throws \BadMethodCallException |
| 65 | 65 | */ |
| 66 | - protected function getPoint(ServerRequestInterface $request) : callable |
|
| 66 | + protected function getPoint(ServerRequestInterface $request) : callable |
|
| 67 | 67 | { |
| 68 | 68 | $controller = $this->getControllerClass($request); |
| 69 | 69 | $this->checkController($controller); |
@@ -81,37 +81,37 @@ discard block |
||
| 81 | 81 | return $this->controller ?? ''; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @param string $controller |
|
| 86 | - * @throws \BadMethodCallException |
|
| 87 | - */ |
|
| 88 | - protected function checkController(string $controller) : void |
|
| 84 | + /** |
|
| 85 | + * @param string $controller |
|
| 86 | + * @throws \BadMethodCallException |
|
| 87 | + */ |
|
| 88 | + protected function checkController(string $controller) : void |
|
| 89 | 89 | { |
| 90 | 90 | if (!class_exists($controller)) { |
| 91 | 91 | throw new \BadMethodCallException('Controller not found'); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * @param \object $controller |
|
| 97 | - * @param string $action |
|
| 98 | - * @throws \BadMethodCallException |
|
| 99 | - */ |
|
| 100 | - protected function checkAction($controller, string $action) : void |
|
| 95 | + /** |
|
| 96 | + * @param \object $controller |
|
| 97 | + * @param string $action |
|
| 98 | + * @throws \BadMethodCallException |
|
| 99 | + */ |
|
| 100 | + protected function checkAction($controller, string $action) : void |
|
| 101 | 101 | { |
| 102 | 102 | if (!method_exists($controller, $action)) { |
| 103 | 103 | throw new \BadMethodCallException('Action not found'); |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - protected function getAction(ServerRequestInterface $request): ?string |
|
| 108 | - { |
|
| 107 | + protected function getAction(ServerRequestInterface $request): ?string |
|
| 108 | + { |
|
| 109 | 109 | $route = $this->getRoute($request); |
| 110 | 110 | $matches = $route->getMatchesParams(); |
| 111 | - return $matches['_action'] ?? $this->action ?? null; |
|
| 112 | - } |
|
| 111 | + return $matches['_action'] ?? $this->action ?? null; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - protected function getRoute(ServerRequestInterface $request): Route |
|
| 114 | + protected function getRoute(ServerRequestInterface $request): Route |
|
| 115 | 115 | { |
| 116 | 116 | return $request->getAttribute('route'); |
| 117 | 117 | } |
@@ -18,13 +18,13 @@ |
||
| 18 | 18 | throw new \BadMethodCallException('Not found controller name for dynamic controller point'); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - return $this->prefix . $this->normalizeClassFromUrl($matches['_controller']); |
|
| 21 | + return $this->prefix.$this->normalizeClassFromUrl($matches['_controller']); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | protected function normalizeClassFromUrl(string $class): string |
| 25 | 25 | { |
| 26 | - return array_reduce(explode('-', $class), function ($prev, $item) { |
|
| 27 | - return $prev . ucfirst($item); |
|
| 26 | + return array_reduce(explode('-', $class), function($prev, $item) { |
|
| 27 | + return $prev.ucfirst($item); |
|
| 28 | 28 | }); |
| 29 | 29 | } |
| 30 | 30 | |