| Conditions | 17 |
| Paths | 33 |
| Total Lines | 77 |
| Code Lines | 56 |
| Lines | 13 |
| Ratio | 16.88 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 2 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 23 | private function loadAdditionalContent(&$views, $route, $routeIndex) |
||
| 24 | { |
||
| 25 | foreach ($views as $id => $view) { |
||
| 26 | $meta = isset($view["data"]["meta"]) |
||
| 27 | ? $view["data"]["meta"] |
||
| 28 | : null; |
||
| 29 | |||
| 30 | if (is_array($meta)) { |
||
| 31 | switch ($meta["type"]) { |
||
| 32 | case "article-toc": |
||
| 33 | $content = $views["main"]["data"]["content"]; |
||
| 34 | $views[$id]["data"]["articleToc"] = $this->di->textFilter->createToc($content); |
||
| 35 | break; |
||
| 36 | |||
| 37 | case "breadcrumb": |
||
| 38 | $views[$id]["data"]["breadcrumb"] = $this->createBreadcrumb($route); |
||
| 39 | break; |
||
| 40 | |||
| 41 | View Code Duplication | case "next-previous": |
|
| 42 | $baseRoute = dirname($routeIndex); |
||
| 43 | list($next, $previous) = $this->findNextAndPrevious($routeIndex); |
||
| 44 | $views[$id]["data"]["next"] = $next; |
||
| 45 | $views[$id]["data"]["previous"] = $previous; |
||
| 46 | break; |
||
| 47 | |||
| 48 | case "single": // OBSOLETE |
||
| 49 | case "content": |
||
| 50 | // Support relative routes |
||
| 51 | $route = $meta["route"]; |
||
| 52 | if (substr_compare($route, "./", 0, 2) === 0) { |
||
| 53 | $route = dirname($routeIndex) . "/" . substr($route, 2); |
||
| 54 | } |
||
| 55 | |||
| 56 | // Get the content |
||
| 57 | $data = $this->getDataForAdditionalRoute($route); |
||
| 58 | $views[$id]["data"] = array_merge_recursive_distinct($views[$id]["data"], $data); |
||
| 59 | break; |
||
| 60 | |||
| 61 | case "columns": |
||
| 62 | $columns = $meta["columns"]; |
||
| 63 | foreach ($columns as $key => $value) { |
||
| 64 | $data = $this->getDataForAdditionalRoute($value["route"]); |
||
| 65 | $columns[$key] = $data; |
||
| 66 | } |
||
| 67 | $views[$id]["data"]["columns"] = $columns; |
||
| 68 | break; |
||
| 69 | |||
| 70 | case "toc-sort": |
||
| 71 | $baseRoute = dirname($routeIndex); |
||
| 72 | $this->orderToc($baseRoute, $meta); |
||
| 73 | break; |
||
| 74 | |||
| 75 | View Code Duplication | case "toc": |
|
| 76 | $baseRoute = dirname($routeIndex); |
||
| 77 | $toc = $this->meta[$baseRoute]["__toc__"]; |
||
| 78 | $this->limitToc($toc, $meta); |
||
| 79 | $views[$id]["data"]["toc"] = $toc; |
||
| 80 | $views[$id]["data"]["meta"] = $meta; |
||
| 81 | break; |
||
| 82 | |||
| 83 | case "author": |
||
| 84 | if (isset($views["main"]["data"]["author"])) { |
||
| 85 | $views[$id]["data"]["author"] = $this->loadAuthorDetails($views["main"]["data"]["author"]); |
||
| 86 | } |
||
| 87 | break; |
||
| 88 | |||
| 89 | case "copy": |
||
| 90 | $viewToCopy = $views[$id]["data"]["meta"]["view"]; |
||
| 91 | $views[$id]["data"] = $views[$viewToCopy]["data"]; |
||
| 92 | break; |
||
| 93 | |||
| 94 | default: |
||
| 95 | throw new Exception(t("Unsupported data/meta/type '!TYPE' for additional content.", ["!TYPE" => $meta["type"]])); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 244 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.