| Conditions | 5 |
| Paths | 5 |
| Total Lines | 79 |
| Code Lines | 49 |
| 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); |
||
| 14 | public function render(array $parameters, HTMLNode $previous): HTMLNode |
||
| 15 | { |
||
| 16 | $node = HTMLNode::factory( |
||
| 17 | 'nav', |
||
| 18 | ['class' => 'formularium-pagination-wrapper', 'aria-label' => "Page navigation"], |
||
| 19 | HTMLNode::factory( |
||
| 20 | 'ul', |
||
| 21 | ['class' => 'formularium-pagination'], |
||
| 22 | [ |
||
| 23 | HTMLNode::factory( |
||
| 24 | 'li', |
||
| 25 | [ |
||
| 26 | "class" => "formularium-pagination-item", |
||
| 27 | "v-show" => "currentPage > pagesAround", |
||
| 28 | "@click" => "\$emit('page', 1)" |
||
| 29 | ], |
||
| 30 | HTMLNode::factory( |
||
| 31 | 'a', |
||
| 32 | ["class" => "formularium-pagination-link", |
||
| 33 | ":href" => "basePath + '/1'", |
||
| 34 | "@click.prevent" => "" |
||
| 35 | ], |
||
| 36 | "1" |
||
| 37 | ) |
||
| 38 | ), |
||
| 39 | HTMLNode::factory( |
||
| 40 | 'li', |
||
| 41 | ["class" => "formularium-pagination-item", |
||
| 42 | "v-show" => "currentPage > pagesAround" |
||
| 43 | ], |
||
| 44 | "..." |
||
| 45 | ), |
||
| 46 | HTMLNode::factory( |
||
| 47 | 'li', |
||
| 48 | [ |
||
| 49 | "class" => "formularium-pagination-item", |
||
| 50 | "v-for" => "p in pages", |
||
| 51 | "v-bind:key" => "p.page", |
||
| 52 | "@click" => "\$emit('page', p.page)" |
||
| 53 | ], |
||
| 54 | HTMLNode::factory( |
||
| 55 | 'a', |
||
| 56 | [ |
||
| 57 | "class" => "formularium-pagination-link", |
||
| 58 | ":href" => "basePath + /' + p.page", |
||
| 59 | "@click.prevent" => "" |
||
| 60 | ], |
||
| 61 | "{{p.page}}" |
||
| 62 | ), |
||
| 63 | ), |
||
| 64 | HTMLNode::factory( |
||
| 65 | 'li', |
||
| 66 | [ |
||
| 67 | "class" => "formularium-pagination-item", |
||
| 68 | "v-show" => "lastPage > currentPage + pagesAround", |
||
| 69 | ], |
||
| 70 | "..." |
||
| 71 | ) |
||
| 72 | ] |
||
| 73 | ) |
||
| 74 | ); |
||
| 75 | |||
| 76 | foreach ($this->composer->getFrameworks() as $framework) { |
||
| 77 | /** |
||
| 78 | * @var Framework $framework |
||
| 79 | */ |
||
| 80 | $f =$framework->getName(); |
||
| 81 | if ($f === 'HTML' || $f === 'Vue') { |
||
| 82 | continue; |
||
| 83 | } |
||
| 84 | try { |
||
| 85 | $element = $framework->getElement($this->getName()); |
||
| 86 | $node = $element->render($parameters, $node); |
||
| 87 | } catch (ClassNotFoundException $e) { |
||
| 88 | continue; // element default |
||
| 89 | } |
||
| 90 | } |
||
| 91 | |||
| 92 | return $node; |
||
| 93 | } |
||
| 151 |