| Conditions | 5 | 
| Paths | 12 | 
| Total Lines | 62 | 
| Code Lines | 35 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| 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 declare(strict_types=1); | ||
| 12 | public function render(array $parameters, HTMLNode $previous): HTMLNode | ||
| 13 |     { | ||
| 14 | $base = HTMLNode::factory( | ||
| 15 | 'div', | ||
| 16 | [ | ||
| 17 | 'class' => 'formularium-card card' | ||
| 18 | ] | ||
| 19 | ); | ||
| 20 | |||
| 21 |         if ($parameters[HTMLCard::IMAGE] ?? false) { | ||
| 22 | $image = HTMLNode::factory( | ||
| 23 | 'img', | ||
| 24 | [ | ||
| 25 | 'class' => 'card-img-top', | ||
| 26 | 'src' => $parameters[HTMLCard::IMAGE], | ||
| 27 | 'alt' => '' // TODO | ||
| 28 | ] | ||
| 29 | ); | ||
| 30 | $base->appendContent($image); | ||
| 31 | } | ||
| 32 | |||
| 33 | $body = HTMLNode::factory( | ||
| 34 | 'div', | ||
| 35 | [ | ||
| 36 | 'class' => 'card-body' | ||
| 37 | ] | ||
| 38 | ); | ||
| 39 | $base->appendContent($body); | ||
| 40 | |||
| 41 | // title | ||
| 42 |         if ($parameters[HTMLCard::TITLE] ?? false) { | ||
| 43 | $titleData = null; | ||
| 44 |             if ($parameters[HTMLCard::LINK] ?? false) { | ||
| 45 | $titleData = HTMLNode::factory( | ||
| 46 | 'a', | ||
| 47 | [ 'href' => $parameters[HTMLCard::LINK] ], | ||
| 48 | $parameters[HTMLCard::TITLE] | ||
| 49 | ); | ||
| 50 |             } else { | ||
| 51 | $titleData = $parameters[HTMLCard::TITLE]; | ||
| 52 | } | ||
| 53 | $title = HTMLNode::factory( | ||
| 54 | 'h5', | ||
| 55 | [ | ||
| 56 | 'class' => 'card-title' | ||
| 57 | ], | ||
| 58 | $titleData | ||
| 59 | ); | ||
| 60 | $body->appendContent($title); | ||
| 61 | } | ||
| 62 | |||
| 63 |         if ($parameters[HTMLCard::CONTENT] ?? false) { | ||
| 64 | $content = HTMLNode::factory( | ||
| 65 | 'div', | ||
| 66 | [ | ||
| 67 | 'class' => 'card-text' | ||
| 68 | ], | ||
| 69 | $parameters[HTMLCard::CONTENT] | ||
| 70 | ); | ||
| 71 | $body->appendContent($content); | ||
| 72 | } | ||
| 73 | return $base; | ||
| 74 | } | ||
| 82 |