| Conditions | 11 |
| Paths | 192 |
| Total Lines | 35 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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); |
||
| 11 | public function render(array $parameters, HTMLNode $previous): HTMLNode |
||
| 12 | { |
||
| 13 | foreach ($previous->get('.formularium-disabled') as $e) { |
||
| 14 | $e->addAttribute('class', 'disabled'); |
||
| 15 | } |
||
| 16 | foreach ($previous->get('.formularium-pagination-item') as $e) { |
||
| 17 | $e->addAttribute('class', 'page-item'); |
||
| 18 | } |
||
| 19 | foreach ($previous->get('.formularium-pagination-ellipsis') as $e) { |
||
| 20 | $e->addAttribute('class', 'disabled'); |
||
| 21 | } |
||
| 22 | foreach ($previous->get('.formularium-pagination-link') as $e) { |
||
| 23 | $e->addAttribute('class', 'page-link'); |
||
| 24 | } |
||
| 25 | foreach ($previous->get('.formularium-pagination-current') as $e) { |
||
| 26 | $e->addAttribute('class', 'disabled'); |
||
| 27 | } |
||
| 28 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
| 29 | $e->addAttribute('class', 'pagination'); |
||
| 30 | } |
||
| 31 | |||
| 32 | $size = $parameters[self::SIZE] ?? ''; |
||
| 33 | switch ($size) { |
||
| 34 | case self::SIZE_LARGE: |
||
| 35 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
| 36 | $e->addAttribute('class', 'pagination-lg'); |
||
| 37 | } |
||
| 38 | break; |
||
| 39 | case self::SIZE_SMALL: |
||
| 40 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
| 41 | $e->addAttribute('class', 'pagination-sm'); |
||
| 42 | } |
||
| 43 | break; |
||
| 44 | } |
||
| 45 | return $previous; |
||
| 46 | } |
||
| 48 |