<?php

class Router {

    private $_uri = array();
    private $_method = array();
    /**
     * Variable privada que almacena las rutas agregadas
     * @param $uri
     */
    public function addRouting($uri, $method = null) {
        $this->_uri[] = '/' . trim($uri,'/');
        if ($method != null):
            $this->_method[] = $method;
        endif;
    }

    public function submit() {
        $u = isset($_GET['uri']) ? '/'.$_GET['uri'] : '/';
        $pageBlank = false;
        foreach ($this->_uri as $uKey => $uValue) :
            if (preg_match("#^$uValue$#",$u)) :
                //$temp = explode('::',$this->_method[$uKey]);
                call_user_func($this->_method[$uKey]);
                $pageBlank = true;
            endif;
        endforeach;

        if ( $pageBlank == false ) :
            header('Location: /');
        endif;



    }

}

/*jskahsh aksshak hskahsakshakhska shka shkashka shkashka shkahskahskahsk*/