| Conditions | 9 | 
| Paths | 6 | 
| Total Lines | 66 | 
| Code Lines | 47 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 9 | ||
| Bugs | 1 | 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  | 
            ||
| 64 | public function printTreeJSON(&$treedata, &$attrs, $section = '')  | 
            ||
| 65 |     { | 
            ||
| 66 | $tree_params = [  | 
            ||
| 67 | 'treedata' => &$treedata,  | 
            ||
| 68 | 'attrs' => &$attrs,  | 
            ||
| 69 | 'section' => $section,  | 
            ||
| 70 | ];  | 
            ||
| 71 | $plugin_manager = $this->plugin_manager;  | 
            ||
| 72 |         $plugin_manager->doHook('tree', $tree_params); | 
            ||
| 73 | |||
| 74 | $parent = [];  | 
            ||
| 75 | |||
| 76 |         if (isset($attrs['is_root'])) { | 
            ||
| 77 | $parent = [  | 
            ||
| 78 | 'id' => 'root',  | 
            ||
| 79 | 'children' => true,  | 
            ||
| 80 | 'icon' => \SUBFOLDER . '/assets/images/themes/default/Servers.png',  | 
            ||
| 81 | 'state' => ['opened' => true],  | 
            ||
| 82 |                 'a_attr'   => ['href' => str_replace('//', '/', \SUBFOLDER . '/src/views/servers')], | 
            ||
| 83 |                 'url'      => str_replace('//', '/', \SUBFOLDER . '/src/views/servers?action=tree'), | 
            ||
| 84 | 'text' => 'Servers',  | 
            ||
| 85 | ];  | 
            ||
| 86 |         } elseif (count($treedata) > 0) { | 
            ||
| 87 |             foreach ($treedata as $rec) { | 
            ||
| 88 | $icon = $this->misc->icon(Decorator::get_sanitized_value($attrs['icon'], $rec));  | 
            ||
| 89 |                 if (!empty($attrs['openicon'])) { | 
            ||
| 90 | $icon = $this->misc->icon(Decorator::get_sanitized_value($attrs['openIcon'], $rec));  | 
            ||
| 91 | }  | 
            ||
| 92 | |||
| 93 | $tree = [  | 
            ||
| 94 | 'text' => Decorator::get_sanitized_value($attrs['text'], $rec),  | 
            ||
| 95 | 'id' => sha1(Decorator::get_sanitized_value($attrs['action'], $rec)),  | 
            ||
| 96 | 'icon' => Decorator::get_sanitized_value($icon, $rec),  | 
            ||
| 97 | 'iconaction' => Decorator::get_sanitized_value($attrs['iconAction'], $rec),  | 
            ||
| 98 | 'openicon' => Decorator::get_sanitized_value($icon, $rec),  | 
            ||
| 99 | 'tooltip' => Decorator::get_sanitized_value($attrs['toolTip'], $rec),  | 
            ||
| 100 | 'a_attr' => ['href' => Decorator::get_sanitized_value($attrs['action'], $rec)],  | 
            ||
| 101 | 'children' => false,  | 
            ||
| 102 | ];  | 
            ||
| 103 | $url = Decorator::get_sanitized_value($attrs['branch'], $rec);  | 
            ||
| 104 |                 if ($url && strpos($url, '/src/views') === false) { | 
            ||
| 105 |                     $url = str_replace('//', '/', \SUBFOLDER . '/src/views/' . $url); | 
            ||
| 106 | }  | 
            ||
| 107 |                 if ($url) { | 
            ||
| 108 | $tree['url'] = $url;  | 
            ||
| 109 | $tree['children'] = true;  | 
            ||
| 110 | }  | 
            ||
| 111 | |||
| 112 | //$tree['text'] = '<a href="' . $tree['id'] . '" target="detail">' . $tree['text'] . '</a>';  | 
            ||
| 113 | |||
| 114 | $parent[] = $tree;  | 
            ||
| 115 | }  | 
            ||
| 116 |         } else { | 
            ||
| 117 | $parent = ['children' => false];  | 
            ||
| 118 | }  | 
            ||
| 119 | |||
| 120 |         if (isset($_REQUEST['children'])) { | 
            ||
| 121 | $children = $parent;  | 
            ||
| 122 | $parent = ['children' => $children];  | 
            ||
| 123 | }  | 
            ||
| 124 | |||
| 125 | return $this  | 
            ||
| 126 | ->container  | 
            ||
| 127 | ->responseobj  | 
            ||
| 128 | ->withStatus(200)  | 
            ||
| 129 | ->withJson($parent);  | 
            ||
| 130 | |||
| 151 |