@@ -98,15 +98,15 @@ discard block  | 
                                                    ||
| 98 | 98 |      { | 
                                                        
| 99 | 99 | $this->request = [];  | 
                                                        
| 100 | 100 |          for ($i = 0; $i < $this->router->collection->countRoutes; ++$i) { | 
                                                        
| 101 | -            $this->request['prefix'] = ($this->router->collection->getRoutes('prefix_' . $i) != '') ? $this->router->collection->getRoutes('prefix_' . $i) : ''; | 
                                                        |
| 102 | -            $this->request['subdomain'] = ($this->router->collection->getRoutes('subdomain_' . $i) != '') ? $this->router->collection->getRoutes('subdomain_' . $i) : ''; | 
                                                        |
| 103 | -            foreach ($this->router->collection->getRoutes('routes_' . $i) as $route => $params) { | 
                                                        |
| 101 | +            $this->request['prefix'] = ($this->router->collection->getRoutes('prefix_'.$i) != '') ? $this->router->collection->getRoutes('prefix_'.$i) : ''; | 
                                                        |
| 102 | +            $this->request['subdomain'] = ($this->router->collection->getRoutes('subdomain_'.$i) != '') ? $this->router->collection->getRoutes('subdomain_'.$i) : ''; | 
                                                        |
| 103 | +            foreach ($this->router->collection->getRoutes('routes_'.$i) as $route => $params) { | 
                                                        |
| 104 | 104 | $this->request['params'] = $params;  | 
                                                        
| 105 | 105 | $this->request['collection_index'] = $i;  | 
                                                        
| 106 | 106 |                  if ($this->checkSubdomain($route)) { | 
                                                        
| 107 | 107 | $route = strstr($route, '/');  | 
                                                        
| 108 | -                    $this->request['route'] = preg_replace_callback('#:([\w]+)#', [$this, 'paramMatch'], '/' . trim(trim($this->request['prefix'], '/') . '/' . trim($route, '/'), '/')); | 
                                                        |
| 109 | -                    if ($this->routeMatch('#^' . $this->request['route'] . '$#')) { | 
                                                        |
| 108 | +                    $this->request['route'] = preg_replace_callback('#:([\w]+)#', [$this, 'paramMatch'], '/'.trim(trim($this->request['prefix'], '/').'/'.trim($route, '/'), '/')); | 
                                                        |
| 109 | +                    if ($this->routeMatch('#^'.$this->request['route'].'$#')) { | 
                                                        |
| 110 | 110 | $this->setCallback();  | 
                                                        
| 111 | 111 | return $this->generateTarget();  | 
                                                        
| 112 | 112 | }  | 
                                                        
@@ -122,19 +122,19 @@ discard block  | 
                                                    ||
| 122 | 122 | */  | 
                                                        
| 123 | 123 | private function checkSubdomain($route)  | 
                                                        
| 124 | 124 |      { | 
                                                        
| 125 | - $url = (isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http') . '://' . ($host = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']));  | 
                                                        |
| 125 | + $url = (isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http').'://'.($host = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']));  | 
                                                        |
| 126 | 126 |          $host = explode(':', $host)[0]; | 
                                                        
| 127 | 127 | $domain = $this->router->collection->getDomain($url);  | 
                                                        
| 128 | - if (!empty($this->request['subdomain']) && $route[0] == '/') $route = trim($this->request['subdomain'], '.') . '.' . $domain . $route;  | 
                                                        |
| 128 | + if (!empty($this->request['subdomain']) && $route[0] == '/') $route = trim($this->request['subdomain'], '.').'.'.$domain.$route;  | 
                                                        |
| 129 | 129 |          if ($route[0] == '/') { | 
                                                        
| 130 | 130 | return ($host != $domain) ? false : true;  | 
                                                        
| 131 | 131 |          } elseif ($route[0] != '/' && $host != $domain) { | 
                                                        
| 132 | 132 | $route = substr($route, 0, strpos($route, "/"));  | 
                                                        
| 133 | 133 |              $route = str_replace('{host}', $domain, $route); | 
                                                        
| 134 | 134 |              $route = preg_replace_callback('#{subdomain}#', [$this, 'subdomainMatch'], $route); | 
                                                        
| 135 | -            if (preg_match('#^' . $route . '$#', $host, $this->request['called_subdomain'])) { | 
                                                        |
| 135 | +            if (preg_match('#^'.$route.'$#', $host, $this->request['called_subdomain'])) { | 
                                                        |
| 136 | 136 | $this->request['called_subdomain'] = array_shift($this->request['called_subdomain']);  | 
                                                        
| 137 | -                $this->request['subdomain'] = str_replace('.' . $domain, '', $host); | 
                                                        |
| 137 | +                $this->request['subdomain'] = str_replace('.'.$domain, '', $host); | 
                                                        |
| 138 | 138 | return true;  | 
                                                        
| 139 | 139 | }  | 
                                                        
| 140 | 140 | }  | 
                                                        
@@ -147,7 +147,7 @@ discard block  | 
                                                    ||
| 147 | 147 | private function subdomainMatch()  | 
                                                        
| 148 | 148 |      { | 
                                                        
| 149 | 149 |          if (is_array($this->request['params']) && isset($this->request['params']['subdomain'])) { | 
                                                        
| 150 | -            return '(' . $this->request['params']['subdomain'] . ')'; | 
                                                        |
| 150 | +            return '('.$this->request['params']['subdomain'].')'; | 
                                                        |
| 151 | 151 | }  | 
                                                        
| 152 | 152 | return '([^/]+)';  | 
                                                        
| 153 | 153 | }  | 
                                                        
@@ -160,7 +160,7 @@ discard block  | 
                                                    ||
| 160 | 160 |      { | 
                                                        
| 161 | 161 |          if (is_array($this->request['params']) && isset($this->request['params']['arguments'][$match[1]])) { | 
                                                        
| 162 | 162 |              $this->request['params']['arguments'][$match[1]] = str_replace('(', '(?:', $this->request['params']['arguments'][$match[1]]); | 
                                                        
| 163 | -            return '(' . $this->request['params']['arguments'][$match[1]] . ')'; | 
                                                        |
| 163 | +            return '('.$this->request['params']['arguments'][$match[1]].')'; | 
                                                        |
| 164 | 164 | }  | 
                                                        
| 165 | 165 | return '([^/]+)';  | 
                                                        
| 166 | 166 | }  | 
                                                        
@@ -171,7 +171,7 @@ discard block  | 
                                                    ||
| 171 | 171 | */  | 
                                                        
| 172 | 172 | private function routeMatch($regex)  | 
                                                        
| 173 | 173 |      { | 
                                                        
| 174 | - $regex = (substr($this->request['route'], -1) == '*') ? '#^' . $this->request['route'] . '#' : $regex;  | 
                                                        |
| 174 | + $regex = (substr($this->request['route'], -1) == '*') ? '#^'.$this->request['route'].'#' : $regex;  | 
                                                        |
| 175 | 175 |          if (preg_match($regex, $this->router->route->getUrl(), $this->request['parameters'])) { | 
                                                        
| 176 | 176 | array_shift($this->request['parameters']);  | 
                                                        
| 177 | 177 | return true;  | 
                                                        
@@ -206,9 +206,9 @@ discard block  | 
                                                    ||
| 206 | 206 |          $this->checkRequest('prefix'); | 
                                                        
| 207 | 207 | $this->router->route->setDetail($this->request);  | 
                                                        
| 208 | 208 | $this->router->route->setTarget($target);  | 
                                                        
| 209 | -        $this->router->route->addTarget('block', $this->router->collection->getRoutes('block_' . $index)); | 
                                                        |
| 210 | -        $this->router->route->addTarget('view_dir', $this->router->collection->getRoutes('view_dir_' . $index)); | 
                                                        |
| 211 | -        $this->router->route->addTarget('params', $this->router->collection->getRoutes('params_' . $index)); | 
                                                        |
| 209 | +        $this->router->route->addTarget('block', $this->router->collection->getRoutes('block_'.$index)); | 
                                                        |
| 210 | +        $this->router->route->addTarget('view_dir', $this->router->collection->getRoutes('view_dir_'.$index)); | 
                                                        |
| 211 | +        $this->router->route->addTarget('params', $this->router->collection->getRoutes('params_'.$index)); | 
                                                        |
| 212 | 212 | }  | 
                                                        
| 213 | 213 | |
| 214 | 214 | /**  | 
                                                        
@@ -219,8 +219,8 @@ discard block  | 
                                                    ||
| 219 | 219 |          if (strpos($this->request[$key], ':') !== false && isset($this->request['parameters'][0])) { | 
                                                        
| 220 | 220 | $replacements = $this->request['parameters'];  | 
                                                        
| 221 | 221 | $keys = [];  | 
                                                        
| 222 | - $this->request['@' . $key] = $this->request[$key];  | 
                                                        |
| 223 | -            $this->request[$key] = preg_replace_callback('#:([\w]+)#', function ($matches) use (&$replacements, &$keys) { | 
                                                        |
| 222 | + $this->request['@'.$key] = $this->request[$key];  | 
                                                        |
| 223 | +            $this->request[$key] = preg_replace_callback('#:([\w]+)#', function($matches) use (&$replacements, &$keys) { | 
                                                        |
| 224 | 224 | $keys[$matches[0]] = $replacements[0];  | 
                                                        
| 225 | 225 | return array_shift($replacements);  | 
                                                        
| 226 | 226 | }, $this->request[$key]);  | 
                                                        
@@ -335,7 +335,7 @@ discard block  | 
                                                    ||
| 335 | 335 |              $routes = explode('@', $callback); | 
                                                        
| 336 | 336 | if (!isset($routes[1])) $routes[1] = 'index';  | 
                                                        
| 337 | 337 |              if ($routes[1] == '{method}') { | 
                                                        
| 338 | -                $params = explode('/', preg_replace('#' . str_replace('*', '', $this->request['route']) . '#', '', $this->router->route->getUrl())); | 
                                                        |
| 338 | +                $params = explode('/', preg_replace('#'.str_replace('*', '', $this->request['route']).'#', '', $this->router->route->getUrl())); | 
                                                        |
| 339 | 339 | $routes[1] = empty($params[0]) ? 'index' : $params[0];  | 
                                                        
| 340 | 340 | $this->request['@method'] = $routes[1];  | 
                                                        
| 341 | 341 | array_shift($params);  | 
                                                        
@@ -346,7 +346,7 @@ discard block  | 
                                                    ||
| 346 | 346 | $index = isset($this->request['collection_index']) ? $this->request['collection_index'] : 0;  | 
                                                        
| 347 | 347 | $class = (class_exists($routes[0]))  | 
                                                        
| 348 | 348 | ? $routes[0]  | 
                                                        
| 349 | - : $this->router->collection->getRoutes()['ctrl_namespace_' . $index] . $routes[0];  | 
                                                        |
| 349 | + : $this->router->collection->getRoutes()['ctrl_namespace_'.$index].$routes[0];  | 
                                                        |
| 350 | 350 |              if (method_exists($class, $routes[1])) { | 
                                                        
| 351 | 351 | return [  | 
                                                        
| 352 | 352 | 'dispatcher' => $this->dispatcher['isController'],  | 
                                                        
@@ -356,7 +356,7 @@ discard block  | 
                                                    ||
| 356 | 356 | ];  | 
                                                        
| 357 | 357 | }  | 
                                                        
| 358 | 358 |              if (!strpos($callback, '{method}') !== false) { | 
                                                        
| 359 | -                throw new \Exception('The required method "' . $routes[1] . '" is not found in "' . $class . '"'); | 
                                                        |
| 359 | +                throw new \Exception('The required method "'.$routes[1].'" is not found in "'.$class.'"'); | 
                                                        |
| 360 | 360 | }  | 
                                                        
| 361 | 361 | }  | 
                                                        
| 362 | 362 | return false;  | 
                                                        
@@ -374,13 +374,13 @@ discard block  | 
                                                    ||
| 374 | 374 |              $path = str_replace('{template}', $replace, trim($callback, '/')); | 
                                                        
| 375 | 375 | $extension = substr(strrchr($path, "."), 1);  | 
                                                        
| 376 | 376 | $index = isset($this->request['collection_index']) ? $this->request['collection_index'] : 0;  | 
                                                        
| 377 | -            $viewDir = $this->router->collection->getRoutes('view_dir_' . $index); | 
                                                        |
| 377 | +            $viewDir = $this->router->collection->getRoutes('view_dir_'.$index); | 
                                                        |
| 378 | 378 | $target = null;  | 
                                                        
| 379 | -            if (in_array('.' . $extension, $this->router->getConfig()['templateExtension']) && (is_file($fullPath = $viewDir . $path) || is_file($fullPath = $path))) { | 
                                                        |
| 379 | +            if (in_array('.'.$extension, $this->router->getConfig()['templateExtension']) && (is_file($fullPath = $viewDir.$path) || is_file($fullPath = $path))) { | 
                                                        |
| 380 | 380 | $target = $fullPath;  | 
                                                        
| 381 | 381 |              } else { | 
                                                        
| 382 | 382 |                  foreach ($this->router->getConfig()['templateExtension'] as $ext) { | 
                                                        
| 383 | -                    if (is_file($fullPath = $viewDir . $path . $ext) || is_file($fullPath = $path . $ext)) { | 
                                                        |
| 383 | +                    if (is_file($fullPath = $viewDir.$path.$ext) || is_file($fullPath = $path.$ext)) { | 
                                                        |
| 384 | 384 | $target = $fullPath;  | 
                                                        
| 385 | 385 | $extension = substr(strrchr($ext, "."), 1);  | 
                                                        
| 386 | 386 | break;  | 
                                                        
@@ -40,7 +40,7 @@  | 
                                                    ||
| 40 | 40 | public function call()  | 
                                                        
| 41 | 41 |      { | 
                                                        
| 42 | 42 |          if (!is_file($this->router->route->getTarget('template'))) { | 
                                                        
| 43 | -            throw new \Exception('Template file not found : "' . $this->router->route->getTarget('template') . '"'); | 
                                                        |
| 43 | +            throw new \Exception('Template file not found : "'.$this->router->route->getTarget('template').'"'); | 
                                                        |
| 44 | 44 | }  | 
                                                        
| 45 | 45 |          $this->setContentType($this->router->route->getTarget('extension')); | 
                                                        
| 46 | 46 |          if (isset($this->router->route->getTarget('callback')[$this->router->route->getTarget('extension')])) { | 
                                                        
@@ -39,7 +39,7 @@ discard block  | 
                                                    ||
| 39 | 39 |      { | 
                                                        
| 40 | 40 | |
| 41 | 41 |          if (!class_exists($this->router->route->getTarget('controller'))) { | 
                                                        
| 42 | -            throw new \Exception('Class not found : "' . $this->router->route->getTarget('controller') . '"'); | 
                                                        |
| 42 | +            throw new \Exception('Class not found : "'.$this->router->route->getTarget('controller').'"'); | 
                                                        |
| 43 | 43 | }  | 
                                                        
| 44 | 44 | |
| 45 | 45 | $classInstance = [  | 
                                                        
@@ -92,7 +92,7 @@ discard block  | 
                                                    ||
| 92 | 92 |      { | 
                                                        
| 93 | 93 |          $reflector = new ReflectionClass($this->router->route->getTarget('controller')); | 
                                                        
| 94 | 94 |          if (!$reflector->isInstantiable()) { | 
                                                        
| 95 | -            throw new \Exception('Target [' . $this->router->route->getTarget('controller') . '] is not instantiable.'); | 
                                                        |
| 95 | +            throw new \Exception('Target ['.$this->router->route->getTarget('controller').'] is not instantiable.'); | 
                                                        |
| 96 | 96 | }  | 
                                                        
| 97 | 97 | $constructor = $reflector->getConstructor();  | 
                                                        
| 98 | 98 |          if (is_null($constructor)) { |