Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 33 |
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 |
||
28 | public function dataOptions(): array |
||
29 | { |
||
30 | return [ |
||
31 | [ |
||
32 | new IsTrue(), |
||
33 | [ |
||
34 | 'trueValue' => '1', |
||
35 | 'strict' => false, |
||
36 | 'message' => [ |
||
37 | 'template' => 'The value must be "{true}".', |
||
38 | 'parameters' => [ |
||
39 | 'true' => '1', |
||
40 | ], |
||
41 | ], |
||
42 | 'skipOnEmpty' => false, |
||
43 | 'skipOnError' => false, |
||
44 | ], |
||
45 | ], |
||
46 | [ |
||
47 | new IsTrue(trueValue: true, strict: true), |
||
48 | [ |
||
49 | 'trueValue' => true, |
||
50 | 'strict' => true, |
||
51 | 'message' => [ |
||
52 | 'template' => 'The value must be "{true}".', |
||
53 | 'parameters' => [ |
||
54 | 'true' => 'true', |
||
55 | ], |
||
56 | ], |
||
57 | 'skipOnEmpty' => false, |
||
58 | 'skipOnError' => false, |
||
59 | ], |
||
60 | ], |
||
61 | [ |
||
62 | new IsTrue( |
||
63 | trueValue: 'YES', |
||
64 | strict: true, |
||
65 | message: 'Custom message.', |
||
66 | skipOnEmpty: true, |
||
67 | skipOnError: true |
||
68 | ), |
||
69 | [ |
||
70 | 'trueValue' => 'YES', |
||
71 | 'strict' => true, |
||
72 | 'message' => [ |
||
73 | 'template' => 'Custom message.', |
||
74 | 'parameters' => [ |
||
75 | 'true' => 'YES', |
||
76 | ], |
||
77 | ], |
||
78 | 'skipOnEmpty' => true, |
||
79 | 'skipOnError' => true, |
||
80 | ], |
||
129 |