| Conditions | 13 |
| Paths | 432 |
| Total Lines | 40 |
| Code Lines | 26 |
| 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); |
||
| 10 | public function render(array $parameters, HTMLNode $previous): HTMLNode |
||
| 11 | { |
||
| 12 | foreach ($previous->get('.formularium-pagination-wrapper') as $e) { |
||
| 13 | $e->addAttribute('class', 'pagination'); |
||
| 14 | } |
||
| 15 | foreach ($previous->get('.formularium-disabled') as $e) { |
||
| 16 | $e->addAttribute('class', 'disabled'); |
||
| 17 | } |
||
| 18 | foreach ($previous->get('.formularium-ellipsis') as $e) { |
||
| 19 | foreach ($e->getContent() as $e2) { |
||
| 20 | $e2->setAttribute('class', 'pagination-ellipsis') |
||
| 21 | ->setTag('span'); |
||
| 22 | } |
||
| 23 | } |
||
| 24 | foreach ($previous->get('.formularium-pagination-link') as $e) { |
||
| 25 | $e->addAttribute('class', 'pagination-link'); |
||
| 26 | } |
||
| 27 | foreach ($previous->get('.formularium-pagination-current') as $e) { |
||
| 28 | foreach ($e->getContent() as $e2) { |
||
| 29 | $e2->addAttribute('class', 'is-current'); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
| 33 | $e->addAttribute('class', 'pagination-list'); |
||
| 34 | } |
||
| 35 | |||
| 36 | $size = $parameters[self::SIZE] ?? ''; |
||
| 37 | switch ($size) { |
||
| 38 | case self::SIZE_LARGE: |
||
| 39 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
| 40 | $e->addAttribute('class', 'is-large'); |
||
| 41 | } |
||
| 42 | break; |
||
| 43 | case self::SIZE_SMALL: |
||
| 44 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
| 45 | $e->addAttribute('class', 'is-small'); |
||
| 46 | } |
||
| 47 | break; |
||
| 48 | } |
||
| 49 | return $previous; |
||
| 50 | } |
||
| 52 |