public static function execute($currentRoute)
    {
        $currentRouteParts = explode('/', $currentRoute);

        foreach (self::$routes as $route) {

            // Check if route matches complete URL.
            if ($route['url'] == $currentRoute) {
                return self::callController($route);
            }

            // Exploding route parts for dynamic checking.
            $routeParts = explode('/', $route['url']);

            // If route parts does not match current URL parts, continue.
            if (count($currentRouteParts) !== count($routeParts)) {
                continue;
            }

            $parts = count($routeParts) - 1;
            $valid = true;
            $properties = [];

            foreach ($routeParts as $key => $routePart) {
                $dynamicRoute = false;

                // Current route is not valid, continuing.
                if (! $valid) {
                    continue;
                }

                // Current route part is dynamic, add to array.
                if (substr($routePart, 0, 1) == '{' && substr($routePart, -1, 1) == '}') {
                    $properties[substr($routePart, 1, -1)] = $currentRouteParts[$key];
                    $dynamicRoute = true;
                }

                // If is not dynamic part, and does not match current URL part, make route invalid and continue.
                if (! $dynamicRoute && $routePart != $currentRouteParts[$key]) {
                    $valid = false;
                    continue;
                }

                // Check passed, call controller for current route.
                if ($key == $parts && $valid == true) {
                    return self::callController($route, $properties);
                }
            }
        }

        // No valid route for current route, throw exception.
        throw new RouteNotFoundException($currentRoute);
    }
public static function execute($currentRoute)
    {
        $currentRouteParts = explode('/', $currentRoute);

        foreach (self::$routes as $route) {

            // Check if route matches complete URL.
            if ($route['url'] == $currentRoute) {
                return self::callController($route);
            }

            // Exploding route parts for dynamic checking.
            $routeParts = explode('/', $route['url']);

            // If route parts does not match current URL parts, continue.
            if (count($currentRouteParts) !== count($routeParts)) {
                continue;
            }

            $parts = count($routeParts) - 1;
            $valid = true;
            $properties = [];

            foreach ($routeParts as $key => $routePart) {
                $dynamicRoute = false;

                // Current route is not valid, continuing.
                if (! $valid) {
                    continue;
                }

                // Current route part is dynamic, add to array.
                if (substr($routePart, 0, 1) == '{' && substr($routePart, -1, 1) == '}') {
                    $properties[substr($routePart, 1, -1)] = $currentRouteParts[$key];
                    $dynamicRoute = true;
                }

                // If is not dynamic part, and does not match current URL part, make route invalid and continue.
                if (! $dynamicRoute && $routePart != $currentRouteParts[$key]) {
                    $valid = false;
                    continue;
                }

                // Check passed, call controller for current route.
                if ($key == $parts && $valid == true) {
                    return self::callController($route, $properties);
                }
            }
        }

        // No valid route for current route, throw exception.
        throw new RouteNotFoundException($currentRoute);
    }
public static function execute ( $ currentRoute ) { $ currentRouteParts = explode ( '/' , $ currentRoute ) ; foreach ( self :: $ routes as $ route ) { // Check if route matches complete URL. if ( $ route [ 'url' ] == $ currentRoute ) { return self :: callController ( $ route ) ; } // Exploding route parts for dynamic checking. $ routeParts = explode ( '/' , $ route [ 'url' ] ) ; // If route parts does not match current URL parts, continue. if ( count ( $ currentRouteParts ) !== count ( $ routeParts ) ) { continue ; } $ parts = count ( $ routeParts ) - 1 ; $ valid = true ; $ properties = [ ] ; foreach ( $ routeParts as $ key => $ routePart ) { $ dynamicRoute = false ; // Current route is not valid, continuing. if ( ! $ valid ) { continue ; } // Current route part is dynamic, add to array. if ( substr ( $ routePart , 0 , 1 ) == '{' && substr ( $ routePart , - 1 , 1 ) == '}' ) { $ properties [ substr ( $ routePart , 1 , - 1 ) ] = $ currentRouteParts [ $ key ] ; $ dynamicRoute = true ; } // If is not dynamic part, and does not match current URL part, make route invalid and continue. if ( ! $ dynamicRoute && $ routePart != $ currentRouteParts [ $ key ] ) { $ valid = false ; continue ; } // Check passed, call controller for current route. if ( $ key == $ parts && $ valid == true ) { return self :: callController ( $ route , $ properties ) ; } } } // No valid route for current route, throw exception. throw new RouteNotFoundException ( $ currentRoute ) ; }
Execute routing.

@param $currentRoute
@throws RouteNotFoundException
@return
Execute routing .