@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | public function dispatch($routes) |
28 | 28 | { |
29 | 29 | $result = null; |
30 | - foreach($routes as $regex => $callable){ |
|
30 | + foreach ($routes as $regex => $callable) { |
|
31 | 31 | $result = $this->execute($regex, $callable); |
32 | - if($result !== false) return $result; |
|
32 | + if ($result !== false) return $result; |
|
33 | 33 | } |
34 | 34 | return false; |
35 | 35 | } |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function execute($regex, $callable) |
44 | 44 | { |
45 | - if(is_array($callable)){ |
|
45 | + if (is_array($callable)) { |
|
46 | 46 | $callable = end($callable); |
47 | - foreach($callable as $conf){ |
|
48 | - if($conf !== $_SERVER['REQUEST_METHOD']) return false; |
|
47 | + foreach ($callable as $conf) { |
|
48 | + if ($conf !== $_SERVER['REQUEST_METHOD']) return false; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - if(preg_match('/^'.$regex.'$/', $this->base(), $matches)){ |
|
52 | + if (preg_match('/^'.$regex.'$/', $this->base(), $matches)) { |
|
53 | 53 | |
54 | 54 | array_shift($matches); |
55 | 55 | |
56 | - if(is_callable($callable)){ |
|
56 | + if (is_callable($callable)) { |
|
57 | 57 | return call_user_func_array($callable, $matches); |
58 | 58 | } |
59 | 59 | |
60 | 60 | list($class, $method) = explode('@', $callable); |
61 | 61 | |
62 | - $method = !preg_match('/\@/', $callable) ? 'index' : $method ; |
|
62 | + $method = !preg_match('/\@/', $callable) ? 'index' : $method; |
|
63 | 63 | $class = class_exists($class) ? $class : $callable; |
64 | 64 | |
65 | 65 | $c = new $class(); |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | $result = null; |
30 | 30 | foreach($routes as $regex => $callable){ |
31 | 31 | $result = $this->execute($regex, $callable); |
32 | - if($result !== false) return $result; |
|
32 | + if($result !== false) { |
|
33 | + return $result; |
|
34 | + } |
|
33 | 35 | } |
34 | 36 | return false; |
35 | 37 | } |
@@ -45,7 +47,9 @@ discard block |
||
45 | 47 | if(is_array($callable)){ |
46 | 48 | $callable = end($callable); |
47 | 49 | foreach($callable as $conf){ |
48 | - if($conf !== $_SERVER['REQUEST_METHOD']) return false; |
|
50 | + if($conf !== $_SERVER['REQUEST_METHOD']) { |
|
51 | + return false; |
|
52 | + } |
|
49 | 53 | } |
50 | 54 | } |
51 | 55 |