@@ -21,7 +21,6 @@ |
||
21 | 21 | * @param array $args as a variadic to catch all arguments. |
22 | 22 | * |
23 | 23 | * @throws Anax\Route\Exception\NotFoundException when route is not found. |
24 | - |
|
25 | 24 | * @return object as the response. |
26 | 25 | * |
27 | 26 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
@@ -22,7 +22,6 @@ |
||
22 | 22 | * @param string $message with details. |
23 | 23 | * |
24 | 24 | * @throws Anax\Route\Exception\NotFoundException |
25 | - |
|
26 | 25 | * @return object as the response. |
27 | 26 | */ |
28 | 27 | public function catchAll(...$args) : object |
@@ -8,7 +8,7 @@ |
||
8 | 8 | "services" => [ |
9 | 9 | "content" => [ |
10 | 10 | "shared" => true, |
11 | - "callback" => function () { |
|
11 | + "callback" => function() { |
|
12 | 12 | $content = new \Anax\Content\FileBasedContent(); |
13 | 13 | $content->setDI($this); |
14 | 14 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | try { |
34 | 34 | $fileContent = $content->contentForRoute(); |
35 | - } catch(NotFoundException $e) { |
|
35 | + } catch (NotFoundException $e) { |
|
36 | 36 | return false; |
37 | 37 | } |
38 | 38 |
@@ -189,18 +189,18 @@ discard block |
||
189 | 189 | |
190 | 190 | // Create level depending on the file id |
191 | 191 | // TODO ciamge doc, can be replaced by __toc__ in meta? |
192 | - $id = (int) $matches[1]; |
|
192 | + $id = (int)$matches[1]; |
|
193 | 193 | $level = 2; |
194 | - if ($id % 100 === 0) { |
|
194 | + if ($id%100 === 0) { |
|
195 | 195 | $level = 0; |
196 | - } elseif ($id % 10 === 0) { |
|
196 | + } elseif ($id%10 === 0) { |
|
197 | 197 | $level = 1; |
198 | 198 | } |
199 | 199 | |
200 | 200 | $index[$key] = [ |
201 | 201 | "file" => $filepath, |
202 | 202 | "section" => $matches[1], |
203 | - "level" => $level, // TODO ? |
|
203 | + "level" => $level, // TODO ? |
|
204 | 204 | "internal" => $this->isInternalRoute($filepath), |
205 | 205 | "tocable" => $this->allowInToc($filepath), |
206 | 206 | ]; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | private function allowInToc($filepath) |
249 | 249 | { |
250 | - return (boolean) preg_match($this->allowedInTocPattern, $filepath); |
|
250 | + return (boolean)preg_match($this->allowedInTocPattern, $filepath); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | // on debg? |
700 | 700 | $content["frontmatter"] = $filtered->frontmatter; |
701 | 701 | |
702 | - return (object) $content; |
|
702 | + return (object)$content; |
|
703 | 703 | } |
704 | 704 | |
705 | 705 |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private function loadAndParseRoute($route) |
75 | 75 | { |
76 | - // Get meta into view structure |
|
77 | - $meta = $this->getMetaForRoute($route); |
|
78 | - unset($meta["__toc__"]); |
|
79 | - unset($meta["views"]); |
|
76 | + // Get meta into view structure |
|
77 | + $meta = $this->getMetaForRoute($route); |
|
78 | + unset($meta["__toc__"]); |
|
79 | + unset($meta["views"]); |
|
80 | 80 | |
81 | 81 | // Get filtered content from route |
82 | 82 | list($routeIndex, , $filtered) = |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | private function getDataForAdditionalRoute($route) |
118 | 118 | { |
119 | - $filter = $this->config["textfilter"]; |
|
120 | - $textFilter = $this->di->get("textfilter"); |
|
119 | + $filter = $this->config["textfilter"]; |
|
120 | + $textFilter = $this->di->get("textfilter"); |
|
121 | 121 | |
122 | 122 | // Get filtered content from route |
123 | 123 | list($routeIndex, , $filtered) = |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | unset($meta["views"]); |
80 | 80 | |
81 | 81 | // Get filtered content from route |
82 | - list($routeIndex, , $filtered) = |
|
82 | + list($routeIndex,, $filtered) = |
|
83 | 83 | $this->mapRoute2Content($route); |
84 | 84 | |
85 | 85 | // Merge frontmatter with meta |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $textFilter = $this->di->get("textfilter"); |
121 | 121 | |
122 | 122 | // Get filtered content from route |
123 | - list($routeIndex, , $filtered) = |
|
123 | + list($routeIndex,, $filtered) = |
|
124 | 124 | $this->mapRoute2Content($route); |
125 | 125 | |
126 | 126 | // Get meta, remove unneeded details |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $part = $request->getRoute(); |
170 | 170 | |
171 | 171 | // Use callback to url->create() instead of string concat |
172 | - $callback = function ($route) use ($url, $baseurl, $part) { |
|
172 | + $callback = function($route) use ($url, $baseurl, $part) { |
|
173 | 173 | if (!empty($route) && $route[0] == "!") { |
174 | 174 | return $url->asset(substr($route, 1), $baseurl); |
175 | 175 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $url = $this->di->get("url"); |
209 | 209 | |
210 | 210 | // Use callback to url->create() instead of string concat |
211 | - $callback = function ($route) use ($url, $baseurl) { |
|
211 | + $callback = function($route) use ($url, $baseurl) { |
|
212 | 212 | return $url->asset($route, $baseurl); |
213 | 213 | }; |
214 | 214 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | : null; |
66 | 66 | $columns = $meta["columns"]; |
67 | 67 | foreach ($columns as $key => $view) { |
68 | - $views2 = [ "main" => $view ]; |
|
68 | + $views2 = ["main" => $view]; |
|
69 | 69 | $this->loadAdditionalContent($views2, $route, $routeIndex); |
70 | 70 | $columns[$key] = $views2["main"]; |
71 | 71 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $order = $options["orderorder"]; |
223 | 223 | $toc = $this->meta[$baseRoute]["__toc__"]; |
224 | 224 | |
225 | - uksort($toc, function ($a, $b) use ($toc, $orderby, $order) { |
|
225 | + uksort($toc, function($a, $b) use ($toc, $orderby, $order) { |
|
226 | 226 | $a = $toc[$a][$orderby]; |
227 | 227 | $b = $toc[$b][$orderby]; |
228 | 228 | |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | |
260 | 260 | // Check if pagination is currently used |
261 | 261 | if ($this->currentPage) { |
262 | - $options["offset"] = ($this->currentPage - 1) * $options["items"]; |
|
262 | + $options["offset"] = ($this->currentPage - 1)*$options["items"]; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | $meta["totalItems"] = count($toc); |
266 | - $meta["currentPage"] = (int) floor($options["offset"] / $options["items"]) + 1; |
|
267 | - $meta["totalPages"] = (int) floor($meta["totalItems"] / $options["items"] + 1); |
|
266 | + $meta["currentPage"] = (int)floor($options["offset"]/$options["items"]) + 1; |
|
267 | + $meta["totalPages"] = (int)floor($meta["totalItems"]/$options["items"] + 1); |
|
268 | 268 | |
269 | 269 | // Next and previous page |
270 | 270 | $pagination = $this->config["pagination"]; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | |
291 | 291 | |
292 | 292 | // Only use slice of toc |
293 | - $startSlice = ($meta["currentPage"] - 1) * $options["items"]; |
|
293 | + $startSlice = ($meta["currentPage"] - 1)*$options["items"]; |
|
294 | 294 | $toc = array_slice($toc, $startSlice, $options["items"]); |
295 | 295 | $meta["displayedItems"] = count($toc); |
296 | 296 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | "services" => [ |
7 | 7 | "router" => [ |
8 | 8 | "shared" => true, |
9 | - "callback" => function () { |
|
9 | + "callback" => function() { |
|
10 | 10 | $router = new \Anax\Route\Router(); |
11 | 11 | $router->setDI($this); |
12 | 12 |
@@ -16,21 +16,21 @@ discard block |
||
16 | 16 | [ |
17 | 17 | "info" => "Just say hi with a string.", |
18 | 18 | "path" => "hi", |
19 | - "handler" => function () { |
|
19 | + "handler" => function() { |
|
20 | 20 | return "Hi."; |
21 | 21 | }, |
22 | 22 | ], |
23 | 23 | [ |
24 | 24 | "info" => "Say No! with status code 500.", |
25 | 25 | "path" => "no", |
26 | - "handler" => function () { |
|
26 | + "handler" => function() { |
|
27 | 27 | return ["No!", 500]; |
28 | 28 | }, |
29 | 29 | ], |
30 | 30 | [ |
31 | 31 | "info" => "Say Hi through JSON.", |
32 | 32 | "path" => "json", |
33 | - "handler" => function () { |
|
33 | + "handler" => function() { |
|
34 | 34 | return [["message" => "Hi JSON"]]; |
35 | 35 | }, |
36 | 36 | ], |
@@ -47,28 +47,28 @@ discard block |
||
47 | 47 | [ |
48 | 48 | "info" => "Throw standard exception.", |
49 | 49 | "path" => "exception", |
50 | - "handler" => function () { |
|
50 | + "handler" => function() { |
|
51 | 51 | throw new \Exception("Standard \Exception"); |
52 | 52 | }, |
53 | 53 | ], |
54 | 54 | [ |
55 | 55 | "info" => "Try internal 403.", |
56 | 56 | "path" => "403", |
57 | - "handler" => function () { |
|
57 | + "handler" => function() { |
|
58 | 58 | throw new ForbiddenException("Detailed error message."); |
59 | 59 | }, |
60 | 60 | ], |
61 | 61 | [ |
62 | 62 | "info" => "Try internal 404.", |
63 | 63 | "path" => "404", |
64 | - "handler" => function () { |
|
64 | + "handler" => function() { |
|
65 | 65 | throw new NotFoundException("Detailed error message."); |
66 | 66 | }, |
67 | 67 | ], |
68 | 68 | [ |
69 | 69 | "info" => "Try internal 500.", |
70 | 70 | "path" => "500", |
71 | - "handler" => function () { |
|
71 | + "handler" => function() { |
|
72 | 72 | throw new InternalErrorException("Detailed error message."); |
73 | 73 | }, |
74 | 74 | ], |