@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $this->response->setStatusCode(404); |
| 58 | 58 | $this->route = is_null($route) ? new Route() : $route; |
| 59 | 59 | $this->middleware = new Middleware($this); |
| 60 | - $this->config['di'] = function ($class) { |
|
| 60 | + $this->config['di'] = function($class) { |
|
| 61 | 61 | return new $class; |
| 62 | 62 | }; |
| 63 | 63 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | if (is_null($url)) |
| 116 | 116 | $url = (isset($_GET['url'])) ? $_GET['url'] : substr(str_replace(str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']), '', $_SERVER['REQUEST_URI']), 1); |
| 117 | - $this->route->setUrl('/' . trim(explode('?', $url)[0], '/')); |
|
| 117 | + $this->route->setUrl('/'.trim(explode('?', $url)[0], '/')); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @param Route $route |
| 29 | 29 | */ |
| 30 | - public function __construct(Route $route,ResponseInterface $response) |
|
| 30 | + public function __construct(Route $route, ResponseInterface $response) |
|
| 31 | 31 | { |
| 32 | 32 | $this->route = $route; |
| 33 | 33 | $this->response = $response; |
@@ -47,18 +47,18 @@ discard block |
||
| 47 | 47 | ? $count++ |
| 48 | 48 | : $dependencies[] = call_user_func_array($this->route->getTarget('di'), [$arg->getClass()->name]); |
| 49 | 49 | } |
| 50 | - if($count == count($this->route->getParameters()) || ($this->route->getParameters() == '' && $count == 0)) { |
|
| 50 | + if ($count == count($this->route->getParameters()) || ($this->route->getParameters() == '' && $count == 0)) { |
|
| 51 | 51 | $dependencies = array_merge($dependencies, ($this->route->getParameters() == '') ? [] : $this->route->getParameters()); |
| 52 | 52 | if ($this->response->getStatusCode() == 202) |
| 53 | 53 | $this->response->setStatusCode(200); |
| 54 | - if (is_array($content = $reflectionMethod->invokeArgs($this->getController(), $dependencies))){ |
|
| 54 | + if (is_array($content = $reflectionMethod->invokeArgs($this->getController(), $dependencies))) { |
|
| 55 | 55 | $this->route->addTarget('data', $content); |
| 56 | - if(isset($this->route->getParams()['ajax']) && $this->route->getParams()['ajax'] == true){ |
|
| 56 | + if (isset($this->route->getParams()['ajax']) && $this->route->getParams()['ajax'] == true) { |
|
| 57 | 57 | $this->response->setContent(json_encode($content)); |
| 58 | 58 | $this->response->setHeaders(['Content-Type' => 'application/json']); |
| 59 | 59 | } |
| 60 | 60 | } elseif (!is_null($content)) $this->response->setContent($content); |
| 61 | - }else |
|
| 61 | + } else |
|
| 62 | 62 | $this->response->setStatusCode(404); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $reflector = new ReflectionClass($this->route->getTarget('controller')); |
| 73 | 73 | if (!$reflector->isInstantiable()) |
| 74 | - throw new \Exception('Target [' . $this->route->getTarget('controller') . '] is not instantiable.'); |
|
| 74 | + throw new \Exception('Target ['.$this->route->getTarget('controller').'] is not instantiable.'); |
|
| 75 | 75 | $constructor = $reflector->getConstructor(); |
| 76 | 76 | if (is_null($constructor)) { |
| 77 | 77 | $class = $this->route->getTarget('controller'); |
| 78 | - return call_user_func_array($this->route->getTarget('di'),[$class]); |
|
| 78 | + return call_user_func_array($this->route->getTarget('di'), [$class]); |
|
| 79 | 79 | } |
| 80 | 80 | $dependencies = $constructor->getParameters(); |
| 81 | 81 | $arguments = []; |
| 82 | 82 | foreach ($dependencies as $dep) { |
| 83 | 83 | $class = $dep->getClass()->name; |
| 84 | - array_push($arguments, call_user_func_array($this->route->getTarget('di'),[$class])); |
|
| 84 | + array_push($arguments, call_user_func_array($this->route->getTarget('di'), [$class])); |
|
| 85 | 85 | } |
| 86 | 86 | return $reflector->newInstanceArgs($arguments); |
| 87 | 87 | } |