| Conditions | 17 |
| Paths | 31 |
| Total Lines | 79 |
| Code Lines | 59 |
| Lines | 13 |
| Ratio | 16.46 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 3 |
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 | $route = $this->getActiveRoute($meta["route"], $routeIndex); |
||
| 51 | |||
| 52 | // Get the content |
||
| 53 | $data = $this->getDataForAdditionalRoute($route); |
||
| 54 | $views[$id]["data"] = array_merge_recursive_distinct($views[$id]["data"], $data); |
||
| 55 | break; |
||
| 56 | |||
| 57 | case "columns": |
||
| 58 | $columns = $meta["columns"]; |
||
| 59 | foreach ($columns as $key => $value) { |
||
| 60 | $route = $this->getActiveRoute($value["route"], $routeIndex); |
||
| 61 | $data = $this->getDataForAdditionalRoute($route); |
||
| 62 | $columns[$key] = $data; |
||
| 63 | } |
||
| 64 | $views[$id]["data"]["columns"] = $columns; |
||
| 65 | break; |
||
| 66 | |||
| 67 | case "toc-sort": |
||
| 68 | $baseRoute = dirname($routeIndex); |
||
| 69 | $this->orderToc($baseRoute, $meta); |
||
| 70 | break; |
||
| 71 | |||
| 72 | View Code Duplication | case "toc": |
|
| 73 | $baseRoute = dirname($routeIndex); |
||
| 74 | $toc = $this->meta[$baseRoute]["__toc__"]; |
||
| 75 | $this->limitToc($toc, $meta); |
||
| 76 | $views[$id]["data"]["toc"] = $toc; |
||
| 77 | $views[$id]["data"]["meta"] = $meta; |
||
| 78 | break; |
||
| 79 | |||
| 80 | case "book-toc": |
||
| 81 | $toc = $this->meta[$baseRoute]["__toc__"]; |
||
| 82 | $views[$id]["data"]["toc"] = $toc; |
||
| 83 | break; |
||
| 84 | |||
| 85 | case "author": |
||
| 86 | if (isset($views["main"]["data"]["author"])) { |
||
| 87 | $views[$id]["data"]["author"] = $this->loadAuthorDetails($views["main"]["data"]["author"]); |
||
| 88 | } |
||
| 89 | break; |
||
| 90 | |||
| 91 | case "copy": |
||
| 92 | $viewToCopy = $views[$id]["data"]["meta"]["view"]; |
||
| 93 | $views[$id]["data"] = $views[$viewToCopy]["data"]; |
||
| 94 | break; |
||
| 95 | |||
| 96 | default: |
||
| 97 | throw new Exception(t("Unsupported data/meta/type '!TYPE' for additional content.", ["!TYPE" => $meta["type"]])); |
||
| 98 | } |
||
| 99 | } |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 247 |
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.