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