From ad9b49a23ea4d52f8db0550c0481f68de7a0f42a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 23 Nov 2011 08:49:09 -0600 Subject: [PATCH] Extract callback validation into method. --- laravel/routing/route.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/laravel/routing/route.php b/laravel/routing/route.php index 8d4e0286..463c9eaa 100644 --- a/laravel/routing/route.php +++ b/laravel/routing/route.php @@ -61,12 +61,25 @@ public function __construct($key, $callback, $parameters = array()) $this->uris = array_map(array($this, 'extract'), explode(', ', $key)); } - if ( ! $callback instanceof Closure and ! is_array($callback) and ! is_string($callback)) + if ( ! $this->callable($callback)) { throw new \InvalidArgumentException('Invalid route defined for URI ['.$this->key.']'); } } + /** + * Determine if the given route callback is callable. + * + * Route callbacks must be either a Closure, array, or string. + * + * @param mixed $callback + * @return bool + */ + protected function callable($callback) + { + return $callback instanceof Closure or is_array($callback) or is_string($callback); + } + /** * Retrieve the URI from a given route destination. * @@ -226,4 +239,4 @@ public function __call($method, $parameters) throw new \BadMethodCallException("Call to undefined method [$method] on Route class."); } -} +} \ No newline at end of file