Commit ad9b49a2 by Taylor Otwell

Extract callback validation into method.

parent 05e365d0
......@@ -61,13 +61,26 @@ class Route {
$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.
*
* If the request is to the root of the application, a single slash
......@@ -226,4 +239,4 @@ class Route {
throw new \BadMethodCallException("Call to undefined method [$method] on Route class.");
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment