src/core.php
protected function route(array $urls) {
        $path = $this->server->getRoute();

        $call = false;        // This will store the controller and method to call
        $matches = array();   // And this the extracted parameters.

        // First we search for specific method routes.
        $method_routes = preg_grep('/^' . $this->server->getMethod() . ':/i', array_keys($urls));
        foreach($method_routes as $route) {
            $method = $this->server->getMethod() . ':';
            $clean_route = substr($route, strlen($method));
            if(preg_match('%^'. $clean_route .'/?$%i',
                          $this->server->getRoute(), $matches)) {
                $call = $urls[$route];
				break;
            }
        }

        // Do we need to try generic routes?
        if(!$call) {
            foreach($urls as $regex => $proto) {
                if(preg_match('%^'. $regex .'/?$%i',
                              $this->server->getRoute(), $matches)) {
                    $call = $proto;
					break;
                }
            }
        }


        // If we don't have a call at this point, that's a 404.
        if(!$call) {
            throw new NoRouteException("URL, ".$this->server->getWholeRoute().", not found.");
        }

        return array('call' => $call, 'params' => $matches);
    }
protected function route(array $urls) {
        $path = $this->server->getRoute();

        $call = false;        // This will store the controller and method to call
        $matches = array();   // And this the extracted parameters.

        // First we search for specific method routes.
        $method_routes = preg_grep('/^' . $this->server->getMethod() . ':/i', array_keys($urls));
        foreach($method_routes as $route) {
            $method = $this->server->getMethod() . ':';
            $clean_route = substr($route, strlen($method));
            if(preg_match('%^'. $clean_route .'/?$%i',
                          $this->server->getRoute(), $matches)) {
                $call = $urls[$route];
				break;
            }
        }

        // Do we need to try generic routes?
        if(!$call) {
            foreach($urls as $regex => $proto) {
                if(preg_match('%^'. $regex .'/?$%i',
                              $this->server->getRoute(), $matches)) {
                    $call = $proto;
					break;
                }
            }
        }


        // If we don't have a call at this point, that's a 404.
        if(!$call) {
            throw new NoRouteException("URL, ".$this->server->getWholeRoute().", not found.");
        }

        return array('call' => $call, 'params' => $matches);
    }
protected function route ( array $ urls ) { $ path = $ this -> server -> getRoute ( ) ; $ call = false ; // This will store the controller and method to call $ matches = array ( ) ; // And this the extracted parameters. // First we search for specific method routes. $ method_routes = preg_grep ( '/^' . $ this -> server -> getMethod ( ) . ':/i' , array_keys ( $ urls ) ) ; foreach ( $ method_routes as $ route ) { $ method = $ this -> server -> getMethod ( ) . ':' ; $ clean_route = substr ( $ route , strlen ( $ method ) ) ; if ( preg_match ( '%^' . $ clean_route . '/?$%i' , $ this -> server -> getRoute ( ) , $ matches ) ) { $ call = $ urls [ $ route ] ; break ; } } // Do we need to try generic routes? if ( ! $ call ) { foreach ( $ urls as $ regex => $ proto ) { if ( preg_match ( '%^' . $ regex . '/?$%i' , $ this -> server -> getRoute ( ) , $ matches ) ) { $ call = $ proto ; break ; } } } // If we don't have a call at this point, that's a 404. if ( ! $ call ) { throw new NoRouteException ( "URL, " . $ this -> server -> getWholeRoute ( ) . ", not found." ) ; } return array ( 'call' => $ call , 'params' => $ matches ) ; }
Does the actual URL routing.

The main method of the Core class.

@param   array    	$urls  	    The regex-based url to class mapping
@throws  NoHandlerException      Thrown if corresponding class is not found
@throws  NoRouteException        Thrown if no match is found
@throws  BadMethodCallException  Thrown if a corresponding GET,POST is not found
Does the actual URL routing .