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