Conditions | 12 |
Paths | 49 |
Total Lines | 51 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 0 | Features | 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 |
||
171 | private function buildText(array $routes, int $indent = 0) |
||
172 | { |
||
173 | $templateContent = ''; |
||
174 | foreach ($routes as $route_key => $route) { |
||
175 | $templateString = ''; |
||
176 | $tabs = (isset($route['prefix']) === true) ? (($indent * 3) + 3) : 0; |
||
177 | if (isset($route['custom']) === true) { |
||
178 | foreach ($route['custom'] as $custom_key => $custom) { |
||
179 | if (true === isset($custom['function']) && $custom['function'] !== '') { |
||
180 | $custom['function'] = '@'.$custom['function']; |
||
181 | } |
||
182 | $vars = [ |
||
183 | '$ITERATION_CUSTOM_METHOD$' => $custom['method'], |
||
184 | '$ITERATION_CUSTOM_ENDPOINT$' => $custom['endpoint'], |
||
185 | '$ITERATION_CUSTOM_CONTROLLER$' => $custom['controller'], |
||
186 | '$ITERATION_CUSTOM_FUNCTION$' => $custom['function'], |
||
187 | '$ITERATION_CUSTOM_NAME$' => $custom['name'], |
||
188 | '$INDENT$' => infy_tabs($tabs), |
||
189 | ]; |
||
190 | $templateString .= get_artomator_template('scaffold.routes.prefixed.custom'); |
||
191 | $templateString = fill_template($vars, $templateString); |
||
192 | } |
||
193 | } |
||
194 | if (isset($route['resources'])) { |
||
195 | $tabs = (isset($route['prefix'])) ? (($indent * 3) + 3) : 0; |
||
196 | foreach (array_keys($route['resources']) as $resource_key) { |
||
197 | $vars = [ |
||
198 | '$ITERATION_MODEL_NAME_PLURAL_CAMEL$' => Str::camel(Str::plural($resource_key)), |
||
199 | '$ITERATION_MODEL_NAME$' => $resource_key, |
||
200 | '$INDENT$' => infy_tabs($tabs), |
||
201 | ]; |
||
202 | $templateString .= get_artomator_template('scaffold.routes.prefixed.route'); |
||
203 | $templateString = fill_template($vars, $templateString); |
||
204 | } |
||
205 | } |
||
206 | if ((isset($route['group'])) === true) { |
||
207 | $templateString .= $this->buildText($route['group'], ($indent + 1)); |
||
208 | } |
||
209 | if ((isset($route['prefix'])) === true) { |
||
210 | $vars = [ |
||
211 | '$ITERATION_NAMESPACE_CAMEL$' => ucfirst($route_key), |
||
212 | '$ITERATION_NAMESPACE_LOWER$' => strtolower($route_key), |
||
213 | '$INDENT$' => infy_tabs($indent * 3), |
||
214 | ]; |
||
215 | $templateString = get_artomator_template('scaffold.routes.prefixed.namespace').$templateString.get_artomator_template('scaffold.routes.prefixed.closure'); |
||
216 | $templateString = fill_template($vars, $templateString); |
||
217 | } |
||
218 | $templateContent .= $templateString; |
||
219 | } |
||
220 | |||
221 | return $templateContent; |
||
222 | } |
||
224 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.