Conditions | 11 |
Paths | 192 |
Total Lines | 35 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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); |
||
27 | protected function fix($value, Field $field, HTMLElement $previous): HTMLElement |
||
|
|||
28 | { |
||
29 | foreach ($previous->get('.formularium-disabled') as $e) { |
||
30 | $e->addAttribute('class', 'disabled'); |
||
31 | } |
||
32 | foreach ($previous->get('.formularium-pagination-item') as $e) { |
||
33 | $e->addAttribute('class', 'page-item'); |
||
34 | } |
||
35 | foreach ($previous->get('.formularium-pagination-ellipsis') as $e) { |
||
36 | $e->addAttribute('class', 'disabled'); |
||
37 | } |
||
38 | foreach ($previous->get('.formularium-pagination-link') as $e) { |
||
39 | $e->addAttribute('class', 'page-link'); |
||
40 | } |
||
41 | foreach ($previous->get('.formularium-pagination-current') as $e) { |
||
42 | $e->addAttribute('class', 'disabled'); |
||
43 | } |
||
44 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
45 | $e->addAttribute('class', 'pagination'); |
||
46 | } |
||
47 | |||
48 | $size = $field->getExtension(Renderable::SIZE, ''); |
||
49 | switch ($size) { |
||
50 | case Renderable::SIZE_LARGE: |
||
51 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
52 | $e->addAttribute('class', 'pagination-lg'); |
||
53 | } |
||
54 | break; |
||
55 | case Renderable::SIZE_SMALL: |
||
56 | foreach ($previous->get('.formularium-pagination') as $e) { |
||
57 | $e->addAttribute('class', 'pagination-sm'); |
||
58 | } |
||
59 | break; |
||
60 | } |
||
61 | return $previous; |
||
62 | } |
||
64 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.