From 6fe6f4b1962299b402a8c5e51d3a716df3bf191e Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Tue, 3 Nov 2015 08:13:51 +0700 Subject: [PATCH] Use `stripos` to compare request method, instead of `explode` + `in_array`. --- AltoRouter.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/AltoRouter.php b/AltoRouter.php index 08871dc..6e55e91 100644 --- a/AltoRouter.php +++ b/AltoRouter.php @@ -189,18 +189,9 @@ class AltoRouter { } foreach($this->routes as $handler) { - list($method, $_route, $target, $name) = $handler; + list($methods, $_route, $target, $name) = $handler; - $methods = explode('|', $method); - $method_match = false; - - // Check if request method matches. If not, abandon early. (CHEAP) - foreach($methods as $method) { - if (strcasecmp($requestMethod, $method) === 0) { - $method_match = true; - break; - } - } + $method_match = (stripos($methods, $requestMethod) !== false); // Method did not match, continue to next route. if(!$method_match) continue;