| Conditions | 5 |
| Paths | 5 |
| Total Lines | 99 |
| Code Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | 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 | [ |
||
| 22 | 'class' => 'formularium-pagination', |
||
| 23 | 'v-if' => 'lastPage > 1' |
||
| 24 | ], |
||
| 25 | [ |
||
| 26 | HTMLNode::factory( |
||
| 27 | 'li', |
||
| 28 | [ |
||
| 29 | "class" => "formularium-pagination-item", |
||
| 30 | "v-show" => "currentPage > pagesAround", |
||
| 31 | "@click" => "\$emit('page', 1)" |
||
| 32 | ], |
||
| 33 | HTMLNode::factory( |
||
| 34 | 'a', |
||
| 35 | [ |
||
| 36 | "class" => "formularium-pagination-link", |
||
| 37 | ":href" => "basePath + '/1'", |
||
| 38 | "@click.prevent" => "" |
||
| 39 | ], |
||
| 40 | "1", |
||
| 41 | true |
||
| 42 | ) |
||
| 43 | ), |
||
| 44 | HTMLNode::factory( |
||
| 45 | 'li', |
||
| 46 | [ |
||
| 47 | "class" => "formularium-pagination-item", |
||
| 48 | "v-show" => "currentPage > pagesAround" |
||
| 49 | ], |
||
| 50 | "...", |
||
| 51 | true |
||
| 52 | ), |
||
| 53 | HTMLNode::factory( |
||
| 54 | 'li', |
||
| 55 | [ |
||
| 56 | "class" => "formularium-pagination-item", |
||
| 57 | "v-for" => "p in pages", |
||
| 58 | "v-bind:key" => "p.page", |
||
| 59 | "@click" => "\$emit('page', p.page)" |
||
| 60 | ], |
||
| 61 | [ |
||
| 62 | HTMLNode::factory( |
||
| 63 | 'a', |
||
| 64 | [ |
||
| 65 | "v-if" => "p.page == currentPage", |
||
| 66 | "class" => ["formularium-pagination-link", "formularium-pagination-current"], |
||
| 67 | ":href" => "baseLink + p.page", |
||
| 68 | "@click.prevent" => "" |
||
| 69 | ], |
||
| 70 | "{{p.page}}" |
||
| 71 | ), |
||
| 72 | HTMLNode::factory( |
||
| 73 | 'a', |
||
| 74 | [ |
||
| 75 | "v-else" => null, |
||
| 76 | "class" => "formularium-pagination-link", |
||
| 77 | ":href" => "baseLink + p.page", |
||
| 78 | "@click.prevent" => "" |
||
| 79 | ], |
||
| 80 | "{{p.page}}" |
||
| 81 | ) |
||
| 82 | ] |
||
| 83 | ), |
||
| 84 | HTMLNode::factory( |
||
| 85 | 'li', |
||
| 86 | [ |
||
| 87 | "class" => "formularium-pagination-item", |
||
| 88 | "v-show" => "lastPage > currentPage + pagesAround", |
||
| 89 | ], |
||
| 90 | "..." |
||
| 91 | ) |
||
| 92 | ] |
||
| 93 | ) |
||
| 94 | ); |
||
| 95 | |||
| 96 | foreach ($this->composer->getFrameworks() as $framework) { |
||
| 97 | /** |
||
| 98 | * @var Framework $framework |
||
| 99 | */ |
||
| 100 | $f =$framework->getName(); |
||
| 101 | if ($f === 'HTML' || $f === 'Vue') { |
||
| 102 | continue; |
||
| 103 | } |
||
| 104 | try { |
||
| 105 | $element = $framework->getElement($this->getName(), $this->composer); |
||
| 106 | $node = $element->render($parameters, $node); |
||
| 107 | } catch (ClassNotFoundException $e) { |
||
| 108 | continue; // element default |
||
| 109 | } |
||
| 110 | } |
||
| 111 | |||
| 112 | return $node; |
||
| 113 | } |
||
| 177 |