@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * @param Route $route |
| 38 | 38 | */ |
| 39 | - public function __construct(Route $route,ResponseInterface $response) |
|
| 39 | + public function __construct(Route $route, ResponseInterface $response) |
|
| 40 | 40 | { |
| 41 | 41 | $this->route = $route; |
| 42 | 42 | $this->response = $response; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $this->response->setContent(call_user_func_array($this->route->getTarget('callback')[$this->route->getTarget('extension')], [$this->route])); |
| 54 | 54 | else { |
| 55 | 55 | ob_start(); |
| 56 | - if(isset($this->route->getTarget()['data']))extract($this->route->getTarget('data')); |
|
| 56 | + if (isset($this->route->getTarget()['data']))extract($this->route->getTarget('data')); |
|
| 57 | 57 | require($this->route->getTarget('template')); |
| 58 | 58 | $this->response->setContent(ob_get_clean()); |
| 59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | /** |
| 63 | 63 | * @param $extension |
| 64 | 64 | */ |
| 65 | - public function setContentType($extension){ |
|
| 65 | + public function setContentType($extension) { |
|
| 66 | 66 | $this->response->setStatusCode(200); |
| 67 | 67 | isset($this->types[$extension]) |
| 68 | 68 | ? $this->response->setHeaders(['Content-Type' => $this->types[$extension]]) |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | * @param ResponseInterface $response |
| 47 | 47 | * @param Route $route |
| 48 | 48 | */ |
| 49 | - public function __construct(RouteCollection $collection,ResponseInterface $response = null,Route $route = null) |
|
| 49 | + public function __construct(RouteCollection $collection, ResponseInterface $response = null, Route $route = null) |
|
| 50 | 50 | { |
| 51 | 51 | $this->collection = $collection; |
| 52 | - $this->response = is_null($response)? new Response() : $response; |
|
| 52 | + $this->response = is_null($response) ? new Response() : $response; |
|
| 53 | 53 | $this->response->setStatusCode(404); |
| 54 | - $this->route = is_null($route)? new Route() : $route; |
|
| 55 | - $this->config['di'] = function($class){ |
|
| 54 | + $this->route = is_null($route) ? new Route() : $route; |
|
| 55 | + $this->config['di'] = function($class) { |
|
| 56 | 56 | return new $class; |
| 57 | 57 | }; |
| 58 | 58 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | /** |
| 77 | 77 | * @param string $matcher |
| 78 | 78 | */ |
| 79 | - public function addMatcher($matcher){ |
|
| 79 | + public function addMatcher($matcher) { |
|
| 80 | 80 | $this->config['matcher'][] = $matcher; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function callTarget() |
| 124 | 124 | { |
| 125 | - $target = is_array($this->route->getTarget('dispatcher'))?$this->route->getTarget('dispatcher'):[$this->route->getTarget('dispatcher')]; |
|
| 126 | - if(!empty($target)) { |
|
| 127 | - foreach($target as $call) { |
|
| 125 | + $target = is_array($this->route->getTarget('dispatcher')) ? $this->route->getTarget('dispatcher') : [$this->route->getTarget('dispatcher')]; |
|
| 126 | + if (!empty($target)) { |
|
| 127 | + foreach ($target as $call) { |
|
| 128 | 128 | $this->dispatcher = new $call($this->route, $this->response); |
| 129 | 129 | call_user_func([$this->dispatcher, 'call']); |
| 130 | 130 | } |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | if (isset($this->route->getDetail()['response_templates']) && isset($this->route->getDetail()['response_templates'][$code = $this->response->getStatusCode()])) { |
| 160 | 160 | $this->route->setCallback($this->route->getDetail()['response_templates'][$code]); |
| 161 | - if(!isset($this->config['matcherInstance'])) |
|
| 161 | + if (!isset($this->config['matcherInstance'])) |
|
| 162 | 162 | foreach ($this->config['matcher'] as $matcher) |
| 163 | 163 | $this->config['matcherInstance'][$matcher] = new $matcher($this); |
| 164 | - foreach($this->config['matcherInstance'] as $instance) { |
|
| 164 | + foreach ($this->config['matcherInstance'] as $instance) { |
|
| 165 | 165 | foreach (call_user_func([$instance, 'getMatcher']) as $match) |
| 166 | - if (is_array($target = call_user_func_array([$instance, $match], [$this->route->getCallback()]))){ |
|
| 167 | - call_user_func_array([$instance, 'setTarget'],[$target]); |
|
| 166 | + if (is_array($target = call_user_func_array([$instance, $match], [$this->route->getCallback()]))) { |
|
| 167 | + call_user_func_array([$instance, 'setTarget'], [$target]); |
|
| 168 | 168 | $this->callTarget(); |
| 169 | 169 | break; |
| 170 | 170 | } |