@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return string|false |
| 79 | 79 | */ |
| 80 | - public function getController(string $controller): false|string |
|
| 80 | + public function getController(string $controller): false | string |
|
| 81 | 81 | {
|
| 82 | 82 | if ($this->enableCache && $this->cache->has(str_replace('/', '_', $controller))) {
|
| 83 | 83 | return $this->cache->get(str_replace('/', '_', $controller));
|
@@ -125,18 +125,18 @@ discard block |
||
| 125 | 125 | {
|
| 126 | 126 | $files = array_slice(\Safe\scandir($this->directory), 2); |
| 127 | 127 | foreach ($files as $file) {
|
| 128 | - if (is_dir($this->directory . '/' . $file)) {
|
|
| 128 | + if (is_dir($this->directory.'/'.$file)) {
|
|
| 129 | 129 | $this->registerDir($file); |
| 130 | - $dir = $this->directory . '/' . $file; |
|
| 130 | + $dir = $this->directory.'/'.$file; |
|
| 131 | 131 | $dir_files = array_slice(\Safe\scandir($dir), 2); |
| 132 | 132 | foreach ($dir_files as $dir_file) {
|
| 133 | - if ($dir_file != 'Main.php' && !\is_dir($dir . '/' . $dir_file)) {
|
|
| 134 | - $this->registerController($file . '/' . \basename($dir_file, '.php'), $this->namespace . '\\' . \ucfirst($file) . '\\' . \basename($dir_file, '.php')); |
|
| 133 | + if ($dir_file != 'Main.php' && !\is_dir($dir.'/'.$dir_file)) {
|
|
| 134 | + $this->registerController($file.'/'.\basename($dir_file, '.php'), $this->namespace.'\\'.\ucfirst($file).'\\'.\basename($dir_file, '.php')); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | - if ($file != 'Main.php' && !\is_dir($this->directory . '/' . $file)) {
|
|
| 139 | - $this->registerController(\basename($file, '.php'), $this->namespace . '\\' . \basename($file, '.php')); |
|
| 138 | + if ($file != 'Main.php' && !\is_dir($this->directory.'/'.$file)) {
|
|
| 139 | + $this->registerController(\basename($file, '.php'), $this->namespace.'\\'.\basename($file, '.php')); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @param string $method |
| 292 | 292 | * @return callable|bool |
| 293 | 293 | */ |
| 294 | - public function getRoute(string $route, string $method): callable|bool |
|
| 294 | + public function getRoute(string $route, string $method): callable | bool |
|
| 295 | 295 | {
|
| 296 | 296 | if (isset($this->route[$method][$route])) {
|
| 297 | 297 | return $this->route[$method][$route]; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | return [0, '', [], $this->debugMsg]; |
| 124 | 124 | } |
| 125 | - $handler = $controller . '::' . $method; |
|
| 125 | + $handler = $controller.'::'.$method; |
|
| 126 | 126 | $arguments = $this->getArguments($controller, $method); |
| 127 | 127 | |
| 128 | 128 | if (is_bool($arguments) && !$arguments) {
|
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | private function getNamespace(): string |
| 141 | 141 | {
|
| 142 | 142 | if ($this->dirMode) {
|
| 143 | - return $this->collection->getNamespace() . '\\' . $this->dir; |
|
| 143 | + return $this->collection->getNamespace().'\\'.$this->dir; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return $this->collection->getNamespace(); |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | if ($this->dirMode && isset($this->pathInfo[0])) {
|
| 166 | - $controller = $this->dir . '/' . ucfirst($this->pathInfo[0]); |
|
| 166 | + $controller = $this->dir.'/'.ucfirst($this->pathInfo[0]); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | //Set corrosponding controller |
| 170 | 170 | if (isset($this->pathInfo[0]) && !empty($this->pathInfo[0])) {
|
| 171 | 171 | $controller = $this->collection->getController($controller); |
| 172 | 172 | } else {
|
| 173 | - $controller = $this->getNamespace() . '\Main'; |
|
| 173 | + $controller = $this->getNamespace().'\Main'; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | if (!$controller) {
|
@@ -181,14 +181,14 @@ discard block |
||
| 181 | 181 | return $controller; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $controller = $this->getNamespace() . '\Main'; |
|
| 184 | + $controller = $this->getNamespace().'\Main'; |
|
| 185 | 185 | |
| 186 | 186 | if (class_exists($controller)) {
|
| 187 | 187 | array_unshift($this->pathInfo, ''); |
| 188 | 188 | return $controller; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - $this->debug('No Controller could be resolved:' . $controller);
|
|
| 191 | + $this->debug('No Controller could be resolved:'.$controller);
|
|
| 192 | 192 | |
| 193 | 193 | return ''; |
| 194 | 194 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param string $method |
| 215 | 215 | * @return bool|array<mixed> |
| 216 | 216 | */ |
| 217 | - private function getArguments(string $controller, string $method): bool|array |
|
| 217 | + private function getArguments(string $controller, string $method): bool | array |
|
| 218 | 218 | {
|
| 219 | 219 | $controllerObj = new $controller; |
| 220 | 220 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | // finally fix the long awaited allIndex bug ! |
| 234 | 234 | if (count($arguments) > count($classMethod->getParameters())) {
|
| 235 | - $this->debug('Not able to resolve ' . $method . 'for' . $controller . 'controller');
|
|
| 235 | + $this->debug('Not able to resolve '.$method.'for'.$controller.'controller');
|
|
| 236 | 236 | return false; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | if (!isset($this->pathInfo[1])) {
|
| 251 | 251 | return false; |
| 252 | 252 | } |
| 253 | - if (method_exists($controller, 'get' . ucfirst($this->pathInfo[1])) || method_exists($controller, 'post' . ucfirst($this->pathInfo[1])) || method_exists($controller, 'put' . ucfirst($this->pathInfo[1])) || method_exists($controller, 'delete' . ucfirst($this->pathInfo[1]))) {
|
|
| 253 | + if (method_exists($controller, 'get'.ucfirst($this->pathInfo[1])) || method_exists($controller, 'post'.ucfirst($this->pathInfo[1])) || method_exists($controller, 'put'.ucfirst($this->pathInfo[1])) || method_exists($controller, 'delete'.ucfirst($this->pathInfo[1]))) {
|
|
| 254 | 254 | return true; |
| 255 | 255 | } |
| 256 | 256 | return false; |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | //Set Method from second argument from URL |
| 271 | 271 | if (isset($this->pathInfo[1])) {
|
| 272 | - if (method_exists($controller, $function = $this->httpMethod . ucfirst($this->pathInfo[1]))) {
|
|
| 272 | + if (method_exists($controller, $function = $this->httpMethod.ucfirst($this->pathInfo[1]))) {
|
|
| 273 | 273 | return $function; |
| 274 | 274 | } |
| 275 | - if (method_exists($controller, $function = 'all' . ucfirst($this->pathInfo[1]))) {
|
|
| 275 | + if (method_exists($controller, $function = 'all'.ucfirst($this->pathInfo[1]))) {
|
|
| 276 | 276 | return $function; |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | if (isset($function)) {
|
| 282 | 282 | $last_function = $function; |
| 283 | 283 | } |
| 284 | - if (method_exists($controller, $function = $this->httpMethod . 'Index')) {
|
|
| 284 | + if (method_exists($controller, $function = $this->httpMethod.'Index')) {
|
|
| 285 | 285 | array_unshift($this->pathInfo, ''); |
| 286 | 286 | return $function; |
| 287 | 287 | } |
@@ -292,11 +292,11 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | if (isset($last_function)) {
|
| 295 | - $this->debug('Neither ' . $function . ' method nor ' . $last_function . ' method you found in ' . $controller . ' controller');
|
|
| 295 | + $this->debug('Neither '.$function.' method nor '.$last_function.' method you found in '.$controller.' controller');
|
|
| 296 | 296 | return ''; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - $this->debug($function . ' method not found in ' . $controller . ' controller'); |
|
| 299 | + $this->debug($function.' method not found in '.$controller.' controller'); |
|
| 300 | 300 | return ''; |
| 301 | 301 | } |
| 302 | 302 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | foreach ($routes[$this->httpMethod] as $pattern => $handler_name) {
|
| 323 | 323 | $pattern = strtr($pattern, $tokens); |
| 324 | - if (\Safe\preg_match('#^/?' . $pattern . '/?$#', $this->uri, $matches)) {
|
|
| 324 | + if (\Safe\preg_match('#^/?'.$pattern.'/?$#', $this->uri, $matches)) {
|
|
| 325 | 325 | $controller = $handler_name; |
| 326 | 326 | $arguments = $matches; |
| 327 | 327 | break; |