Conditions | 17 |
Paths | 121 |
Total Lines | 81 |
Code Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 8 | ||
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 |
||
229 | private function buildText(array $routes, int $indent = 0, string $parent = '') |
||
230 | { |
||
231 | $templateContent = ''; |
||
232 | $fallback = ''; |
||
233 | foreach ($routes as $route_key => $route) { |
||
234 | $templateString = ''; |
||
235 | $tabs = (true === isset($route['prefix'])) ? (($indent * 3) + 3) : 0; |
||
236 | if (true === isset($route['custom'])) { |
||
237 | foreach ($route['custom'] as $custom_key => $custom) { |
||
238 | if (true === isset($custom['function']) && '' !== $custom['function']) { |
||
239 | $custom['function'] = '@'.$custom['function']; |
||
240 | } |
||
241 | $vars = [ |
||
242 | '$ITERATION_CUSTOM_METHOD$' => $custom['method'], |
||
243 | '$ITERATION_CUSTOM_ENDPOINT$' => $custom['endpoint'], |
||
244 | '$ITERATION_CUSTOM_CONTROLLER$' => $custom['controller'], |
||
245 | '$ITERATION_CUSTOM_FUNCTION$' => $custom['function'], |
||
246 | '$ITERATION_CUSTOM_NAME$' => $custom['name'], |
||
247 | '$INDENT$' => infy_tabs($tabs), |
||
248 | ]; |
||
249 | $templateString .= get_artomator_template('scaffold.routes.prefixed.custom'); |
||
250 | $templateString = fill_template($vars, $templateString); |
||
251 | } |
||
252 | } |
||
253 | if (isset($route['resources'])) { |
||
254 | $tabs = (isset($route['prefix'])) ? (($indent * 3) + 3) : 0; |
||
255 | foreach ($route['resources'] as $resource_key => $only) { |
||
256 | if (null === $fallback) { |
||
257 | $fallback = $parent.'.'.$resource_key.'.index'; |
||
258 | } |
||
259 | |||
260 | if (true === is_array($only)) { |
||
261 | $only = '->only([\''.implode('\', \'', $only).'\'])'; |
||
262 | } else { |
||
263 | $only = ''; |
||
264 | } |
||
265 | |||
266 | $className = $parent.'.'.$resource_key; |
||
267 | $className = explode('.', $className); |
||
268 | foreach ($className as &$path) { |
||
269 | $path = ucfirst($path); |
||
270 | } |
||
271 | $className = implode('/', $className); |
||
272 | |||
273 | $this->classNames[] = $className; |
||
274 | |||
275 | $vars = [ |
||
276 | '$ITERATION_MODEL_NAME_PLURAL_CAMEL$' => Str::camel(Str::plural($resource_key)), |
||
277 | '$ITERATION_MODEL_NAME$' => $resource_key, |
||
278 | '$ITERATION_ONLY$' => $only, |
||
279 | '$INDENT$' => infy_tabs($tabs), |
||
280 | ]; |
||
281 | $templateString .= get_artomator_template('scaffold.routes.prefixed.route'); |
||
282 | $templateString = fill_template($vars, $templateString); |
||
283 | } |
||
284 | } |
||
285 | if (true === (isset($route['group']))) { |
||
286 | if ('' !== $parent) { |
||
287 | $parent .= '.'; |
||
288 | } |
||
289 | $parent .= (true === isset($route['prefix'])) ? $route['prefix'] : ''; |
||
290 | $templateString .= $this->buildText($route['group'], ($indent + 1), $parent); |
||
291 | } |
||
292 | if (true === (isset($route['prefix']))) { |
||
293 | $vars = [ |
||
294 | '$ITERATION_NAMESPACE_CAMEL$' => ucfirst($route_key), |
||
295 | '$ITERATION_NAMESPACE_LOWER$' => strtolower($route_key), |
||
296 | '$FALLBACK_ROUTE$' => $fallback, |
||
297 | '$INDENT$' => infy_tabs($indent * 3), |
||
298 | ]; |
||
299 | $templateString = get_artomator_template('scaffold.routes.prefixed.namespace') |
||
300 | .$templateString |
||
301 | .get_artomator_template('scaffold.routes.prefixed.fallback') |
||
302 | .get_artomator_template('scaffold.routes.prefixed.closure'); |
||
303 | |||
304 | $templateString = fill_template($vars, $templateString); |
||
305 | } |
||
306 | $templateContent .= $templateString; |
||
307 | } |
||
308 | |||
309 | return $templateContent; |
||
310 | } |
||
335 |
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.