Skip to content

Commit

Permalink
allow callable invokable
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed May 11, 2017
1 parent 9db3e84 commit c6924b1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Defines a group in which routes may reside.
* `placeholders`, optional, array of regex for path placeholders,
* `middleware`, optional, array of middleware to be added to all group routes

#### Route (Method)
#### Route

Defines the final routes added to Slim

Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/ArrayCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ protected function getSourceMiddleware(array $source): array
* @throws \InvalidArgumentException
* @throws \RuntimeException
*
* @return mixed
* @return string|array|callable
*/
protected function getSourceInvokable(array $source)
{
Expand All @@ -297,7 +297,7 @@ protected function getSourceInvokable(array $source)

$invokable = $source['invokable'];

if (!is_string($invokable) && !is_array($invokable)) {
if (!is_string($invokable) && !is_array($invokable) && !is_callable($invokable)) {
throw new \InvalidArgumentException('Route invokable does not seam to be supported by Slim router');
}

Expand Down
2 changes: 0 additions & 2 deletions src/Source/SourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ protected static function getSourceFromFile(string $file)
switch ($extension) {
case 'php':
return new PhpSource($file);
break;

case 'yml':
case 'yaml':
return new YamlSource($file);
break;
}

throw new \RuntimeException(sprintf('Unknown "%s" extension', $extension));
Expand Down

0 comments on commit c6924b1

Please sign in to comment.