From 7c53090c1e36a8960f6d6b523cd6db615004a7bc Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Wed, 8 Jan 2014 14:39:18 +0100 Subject: [PATCH] Use instance methods to set basePath and matchTypes renamed addMatchType to addMatchTypes --- AltoRouter.php | 10 +++++----- AltoRouterTest.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AltoRouter.php b/AltoRouter.php index ee0759b..840a694 100644 --- a/AltoRouter.php +++ b/AltoRouter.php @@ -22,8 +22,8 @@ class AltoRouter { * @param array $matchTypes */ public function __construct( $routes = array(), $basePath = '', $matchTypes = array() ) { - $this->basePath = $basePath; - $this->matchTypes = array_merge($this->matchTypes, $matchTypes); + $this->setBasePath($basePath); + $this->addMatchTypes($matchTypes); foreach( $routes as $route ) { call_user_func_array(array($this,'map'),$route); @@ -39,11 +39,11 @@ class AltoRouter { } /** - * Add a new named match type. It uses array_merge so keys can be overwritten. + * Add named match types. It uses array_merge so keys can be overwritten. * - * @param array $matchType The key is the name and the value is the regex. + * @param array $matchTypes The key is the name and the value is the regex. */ - public function addMatchType($matchTypes) { + public function addMatchTypes($matchTypes) { $this->matchTypes = array_merge($this->matchTypes, $matchTypes); } diff --git a/AltoRouterTest.php b/AltoRouterTest.php index 16199a0..0474f8a 100644 --- a/AltoRouterTest.php +++ b/AltoRouterTest.php @@ -268,7 +268,7 @@ class AltoRouterTest extends PHPUnit_Framework_TestCase public function testMatchWithCustomNamedRegex() { - $this->router->addMatchType(array('cId' => '[a-zA-Z]{2}[0-9](?:_[0-9]++)?')); + $this->router->addMatchTypes(array('cId' => '[a-zA-Z]{2}[0-9](?:_[0-9]++)?')); $this->router->map('GET', '/bar/[cId:customId]', 'bar_action', 'bar_route'); $this->assertEquals(array(