diff options
-rw-r--r-- | Http/Http.php (renamed from Http.php) | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -34,9 +34,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -namespace Hoa\Router; +namespace Hoa\Router\Http; use Hoa\Core; +use Hoa\Router; /** * Class \Hoa\Router\Http. @@ -48,7 +49,7 @@ use Hoa\Core; * @license New BSD License */ -class Http extends Generic implements Core\Parameter\Parameterizable { +class Http extends Router\Generic implements Core\Parameter\Parameterizable { /** * Secure connection. @@ -211,7 +212,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { $call, $able, Array $variables ) { if(true === $this->ruleExists($id)) - throw new Exception( + throw new Router\Exception( 'Cannot add rule %s because it already exists.', 0, $id); array_walk($methods, function ( &$method ) { @@ -221,7 +222,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { $diff = array_diff($methods, self::$_methods); if(!empty($diff)) - throw new Exception( + throw new Router\Exception( (1 == count($diff) ? 'Method %s is' : 'Methods %s are') . @@ -283,7 +284,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { $prefix = ltrim($prefix, '/'); if(0 === preg_match('#^' . $prefix . '(.*)?$#', $uri, $matches)) - throw new Exception\NotFound( + throw new Router\Exception\NotFound( 'Cannot match the path prefix %s in the URI %s.', 3, [$prefix, $uri]); @@ -332,7 +333,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { ); if(empty($rules)) - throw new Exception\NotFound( + throw new Router\Exception\NotFound( 'No rule to apply to route %s.', 4, $uri); $gotcha = false; @@ -354,7 +355,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { } if(false === $gotcha) - throw new Exception\NotFound( + throw new Router\Exception\NotFound( 'Cannot found an appropriated rule to route %s.', 5, $uri); if(false !== $pos) @@ -470,7 +471,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { && null !== $variables['_subdomain']) { if(empty($variables['_subdomain'])) - throw new Exception( + throw new Router\Exception( 'Subdomain is empty, cannot unroute the rule %s properly.', 6, $id); @@ -579,7 +580,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { if(true === $allowEmpty) return ''; else - throw new Exception( + throw new Router\Exception( 'Variable %s is empty and it is not allowed when ' . 'unrouting rule %s.', 7, [$m, $id]); @@ -656,7 +657,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { return ltrim(@$_SERVER['argv'][1] ?: '', '/'); if(!isset($_SERVER['REQUEST_URI'])) - throw new Exception( + throw new Router\Exception( 'Cannot find URI so we cannot route.', 8); $uri = ltrim(urldecode($_SERVER['REQUEST_URI']), '/'); @@ -679,7 +680,7 @@ class Http extends Generic implements Core\Parameter\Parameterizable { return []; if(!isset($_SERVER['REQUEST_URI'])) - throw new Exception( + throw new Router\Exception( 'Cannot find URI so we cannot get query.', 9); $uri = $_SERVER['REQUEST_URI']; @@ -944,3 +945,8 @@ class Http extends Generic implements Core\Parameter\Parameterizable { : static::UNSECURE; } } + +/** + * Flex entity. + */ +Core\Consistency::flexEntity('Hoa\Router\Http\Http'); |