Source

Ray / Ray / Router.php

Full commit
<?php

namespace Ray;

class Router{

    private $routes = array();
    
    public function map($method, $pattern, $callable){
        $route = $this->routes[$method][$pattern] =  new Router\Route($pattern, $callable);
        
        return $route;
    }
    
    public function proccess($request){

        if(isset($this->routes[$request->method])){
            $active = false;
            
            foreach($this->routes[$request->method] as $route){
                if($route->check($request->uri) === true){
                    $active = $route;
                    break;
                }
            }
            
            if($active){
                return $active->proccess();
            }
        }
        
        return false;
    }
    
}