/**
  * Try and detect the current uri
  *
  * @return string
  */
 public static function detect()
 {
     // create a server object from global
     $server = new Server($_SERVER);
     $try = array('REQUEST_URI', 'PATH_INFO', 'ORIG_PATH_INFO');
     foreach ($try as $method) {
         // make sure the server var exists and is not empty
         if ($server->has($method) and $uri = $server->get($method)) {
             // apply a string filter and make sure we still have somthing left
             if ($uri = filter_var($uri, FILTER_SANITIZE_URL)) {
                 // make sure the uri is not malformed and return the pathname
                 if ($uri = parse_url($uri, PHP_URL_PATH)) {
                     return static::format($uri, $server);
                 }
                 // woah jackie, we found a bad'n
                 throw new ErrorException('Malformed URI');
             }
         }
     }
     throw new OverflowException('Uri was not detected. Make sure the REQUEST_URI is set.');
 }
Пример #2
0
 /**
  * Try and detect the current uri
  *
  * @return string
  */
 private static function detect()
 {
     // create a server object from global vars
     $server = Server::create();
     // make sure the server var exists and is not empty
     if ($server->has('REQUEST_URI') and $uri = $server->get('REQUEST_URI')) {
         // make sure the uri is not malformed and return the pathname
         if ($uri = parse_url($uri, PHP_URL_PATH)) {
             return static::format($uri, $server);
         }
         // woah jackie, we found a bad'n
         throw new ErrorException('Malformed URI');
     }
     throw new OverflowException('Uri was not detected. Make sure the REQUEST_URI is set.');
 }