Conditions | 8 |
Paths | 32 |
Total Lines | 61 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |
||
63 | protected function change(array $array) |
||
64 | { |
||
65 | // Shorten array depth for common elements |
||
66 | $array = $this->common($array); |
||
67 | |||
68 | // Shorten array depth for array elements |
||
69 | $array['required'] = $array['required'][0]; |
||
70 | |||
71 | if (isset($array['required']['attr'][0]['php'])) { |
||
72 | |||
73 | $array['required']['php'] = $array['required']['attr'][0]['php']; |
||
74 | } |
||
75 | |||
76 | // Check for required extensions |
||
77 | if (empty($array['required']['extension'])) { |
||
78 | |||
79 | $array['required']['extension'] = []; |
||
80 | } |
||
81 | |||
82 | // Shorten optional content if found |
||
83 | if (!isset($array['environment'][0]['needed'])) { |
||
84 | |||
85 | $array['environment'][0]['needed'] = []; |
||
86 | |||
87 | } else { |
||
88 | |||
89 | $env = []; |
||
90 | |||
91 | foreach ($array['environment'][0]['needed'] AS $needed) { |
||
92 | |||
93 | if (!isset($needed['version_max'])) { |
||
94 | |||
95 | $needed['version_max'] = ''; |
||
96 | } |
||
97 | |||
98 | $env[] = $needed; |
||
99 | } |
||
100 | |||
101 | $array['environment'][0]['needed'] = $env; |
||
102 | } |
||
103 | |||
104 | if (!isset($array['environment'][0]['extend'])) { |
||
105 | |||
106 | $array['environment'][0]['extend'] = []; |
||
107 | } |
||
108 | |||
109 | // Handle special case for entries |
||
110 | if (!isset($array['entries'][0]['target'])) { |
||
111 | |||
112 | $array['entries'][0]['target'] = []; |
||
113 | } |
||
114 | |||
115 | $array['entries'] = $array['entries'][0]; |
||
116 | |||
117 | $array = $this->_changeAccess($array); |
||
118 | |||
119 | // Set icon URL |
||
120 | $array['icon']['url'] = ''; |
||
121 | |||
122 | return $array; |
||
123 | } |
||
124 | |||
153 |