OSDN Git Service

move disconnected statement from foreach loop
authorJefersson Nathan <admin@phpse.net>
Fri, 23 Dec 2016 14:39:27 +0000 (11:39 -0300)
committerJefersson Nathan <admin@phpse.net>
Fri, 23 Dec 2016 14:39:27 +0000 (11:39 -0300)
src/Router.php

index 4d68044..1d303c4 100755 (executable)
@@ -101,13 +101,14 @@ class Router
      */
     public function match($requestUrl, $requestMethod = 'GET')
     {
+        $currentDir = dirname($_SERVER['SCRIPT_NAME']);
+
         foreach ($this->routes->all() as $routes) {
             // compare server request method with route's allowed http methods
             if (! in_array($requestMethod, (array)$routes->getMethods(), true)) {
                 continue;
             }
 
-            $currentDir = dirname($_SERVER['SCRIPT_NAME']);
             if ('/' !== $currentDir) {
                 $requestUrl = str_replace($currentDir, '', $requestUrl);
             }