Skip to content

Commit

Permalink
Update to v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Apr 14, 2016
1 parent 8018bc6 commit fa3c78f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
13 changes: 13 additions & 0 deletions src/ComponentCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rougin\Slytherin;

/**
* Component Collection
*
* Contains all the required components for Slytherin.
*
* @package Slytherin
* @author Rougin Royce Gutib <rougingutib@gmail.com>
*/
class ComponentCollection extends Components {}
5 changes: 4 additions & 1 deletion src/Dispatching/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class Dispatcher implements DispatcherInterface
*/
protected $router;

/**
* @var array
*/
protected $validHttpMethods = [
'DELETE',
'GET',
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Dispatching/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]]);
Expand Down

0 comments on commit fa3c78f

Please sign in to comment.