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