From fa3c78f09dc789424162ec96c443a896c0460590 Mon Sep 17 00:00:00 2001 From: Rougin Royce Gutib Date: Thu, 14 Apr 2016 17:17:36 +0800 Subject: [PATCH] Update to v0.5.0 --- CHANGELOG.md | 3 ++- src/ComponentCollection.php | 13 +++++++++++++ src/Dispatching/Dispatcher.php | 5 ++++- src/Dispatching/Router.php | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/ComponentCollection.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b1760c8..dfdbe0b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,13 @@ All Notable changes to `Slytherin` will be documented in this file -## [Unreleased](https://github.com/rougin/slytherin/compare/v0.4.3...HEAD) +## [0.5.0](https://github.com/rougin/slytherin/compare/v0.4.3...v0.5.0) 2016-04-14 ### Added - `Middleware` component - `Application::handle` and `Application::toResponse` methods - `HttpKernelInterface` for interoperability +- `ComponentCollection` class ### Changed - PHP version to `v5.4.0` diff --git a/src/ComponentCollection.php b/src/ComponentCollection.php new file mode 100644 index 00000000..56a9ce99 --- /dev/null +++ b/src/ComponentCollection.php @@ -0,0 +1,13 @@ + + */ +class ComponentCollection extends Components {} diff --git a/src/Dispatching/Dispatcher.php b/src/Dispatching/Dispatcher.php index 0db09d2a..34f0533b 100644 --- a/src/Dispatching/Dispatcher.php +++ b/src/Dispatching/Dispatcher.php @@ -20,6 +20,9 @@ class Dispatcher implements DispatcherInterface */ protected $router; + /** + * @var array + */ protected $validHttpMethods = [ 'DELETE', 'GET', @@ -55,7 +58,7 @@ public function dispatch($httpMethod, $uri) foreach ($this->router->getRoutes() as $route) { $hasMatch = preg_match($route[1], $uri, $parameters); - if (! $hasMatch || $httpMethod != $route[0]) { + if ( ! $hasMatch || $httpMethod != $route[0]) { continue; } diff --git a/src/Dispatching/Router.php b/src/Dispatching/Router.php index d9ab4745..abdbbb5e 100644 --- a/src/Dispatching/Router.php +++ b/src/Dispatching/Router.php @@ -41,9 +41,9 @@ public function getRoutes() $routes = []; foreach ($this->routes as $route) { - preg_match('/:[a-z]*/', $route[1], $parameters); + preg_match_all('/:[a-z]*/', $route[1], $parameters); - $pattern = str_replace($parameters, '(\w+)', $route[1]); + $pattern = str_replace($parameters[0], '(\w+)', $route[1]); $pattern = '/^'.str_replace('/', '\/', $pattern).'$/'; array_push($routes, [$route[0], $pattern, $route[2], $route[3]]);