public static function parse()
    {
        self::sortRouteTable();

        $arr = explode("?", $_SERVER["REQUEST_URI"]);
        $name = $arr[0];
        $params = array();
        if (isset($arr[1]) && $arr[1]) {
        $params = explode("&", $arr[1]);
        }

        $newParams = array();
        foreach ($params as $key => $value) {
            $ps = explode("=", $value);
            $newParams[$ps[0]] = $ps[1];
        }
        $arrParams = array();
        foreach($newParams as $k => $v) {
            array_push($arrParams, $k);
        }
        $newParamsPost = array();
        if($_SERVER['REQUEST_METHOD'] == 'POST') {
            $newParamsPost = $_POST;
        }

        $req = new Request();
        $req->setGetParameters($newParams);
        $req->setPostParameters($newParamsPost);
        $controllerName = null;
        $actionName = null;
        foreach(self::$routeTable as $k => $v) {
            if($v[0] == $name) {
                $paramName = array_intersect($v[3], $arrParams);
                if(count($paramName) == count($arrParams)) {
                    $controllerName = $v[1];
                    $actionName = $v[2];
                }
            }
        }
        if($actionName == null && $controllerName == null) {
            echo 'Unknown page'; die;
        }
        $controllerName = ucfirst($controllerName.'Controller');
        $class = new $controllerName();

        return $class->{$actionName.'Action'}($req);
    }
 /**
  * Tests whether passing GET parameters directly in the URL passed to the
  * constructor has the same effect as passing them discretely.
  */
 public function testGetParameterSpecification()
 {
     $request1 = new Request('http://www.foo.bar', array('foo' => 'bar', 'bar' => 'baz'));
     $request2 = new Request('http://www.foo.bar/?foo=bar&bar=baz');
     $this->assertTrue($request1->getURL()->compare($request2->getURL()));
     // This is true even if the verb isn't GET
     $request1->setVerb('POST');
     // Calling this method implicitly sets the verb to POST
     $request2->setPayload(array('baz' => 'boo'));
     $this->assertTrue($request1->getURL()->compare($request2->getURL()));
     /* It's also possible to modify GET parameters after the fact, which
        should have the same effect no matter how the instance was constructed.
        */
     $params = array('a' => 'b', '1' => '2');
     $request1->setGetParameters($params);
     $this->assertEquals('http://www.foo.bar/?a=b&1=2', (string) $request1->getURL());
     $request2->setGetParameters($params);
     $this->assertTrue($request1->getURL()->compare($request2->getURL()));
     /* When GET parameters are specified in both the URL and in the second
        argument, they should be merged, with the latter preferred. */
     $request = new Request('127.0.0.1/?foo=bar&bar=baz', array('bar' => 'foo', 'a' => 'b'));
     $this->assertTrue($request->getURL()->compare('http://127.0.0.1/?foo=bar&bar=foo&a=b'));
 }