Conditions | 1 |
Paths | 1 |
Total Lines | 71 |
Code Lines | 46 |
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 TrueValue(), |
||
33 | [ |
||
34 | 'trueValue' => '1', |
||
35 | 'strict' => false, |
||
36 | 'incorrectInputMessage' => [ |
||
37 | 'template' => 'The allowed types are integer, float, string, boolean. {type} given.', |
||
38 | 'parameters' => [ |
||
39 | 'true' => '1', |
||
40 | ], |
||
41 | ], |
||
42 | 'message' => [ |
||
43 | 'template' => 'The value must be "{true}".', |
||
44 | 'parameters' => [ |
||
45 | 'true' => '1', |
||
46 | ], |
||
47 | ], |
||
48 | 'skipOnEmpty' => false, |
||
49 | 'skipOnError' => false, |
||
50 | ], |
||
51 | ], |
||
52 | [ |
||
53 | new TrueValue(trueValue: true, strict: true), |
||
54 | [ |
||
55 | 'trueValue' => true, |
||
56 | 'strict' => true, |
||
57 | 'incorrectInputMessage' => [ |
||
58 | 'template' => 'The allowed types are integer, float, string, boolean. {type} given.', |
||
59 | 'parameters' => [ |
||
60 | 'true' => 'true', |
||
61 | ], |
||
62 | ], |
||
63 | 'message' => [ |
||
64 | 'template' => 'The value must be "{true}".', |
||
65 | 'parameters' => [ |
||
66 | 'true' => 'true', |
||
67 | ], |
||
68 | ], |
||
69 | 'skipOnEmpty' => false, |
||
70 | 'skipOnError' => false, |
||
71 | ], |
||
72 | ], |
||
73 | [ |
||
74 | new TrueValue( |
||
75 | trueValue: 'YES', |
||
76 | strict: true, |
||
77 | incorrectInputMessage: 'Custom incorrect input message.', |
||
78 | message: 'Custom message.', |
||
79 | skipOnEmpty: true, |
||
80 | skipOnError: true |
||
81 | ), |
||
82 | [ |
||
83 | 'trueValue' => 'YES', |
||
84 | 'strict' => true, |
||
85 | 'incorrectInputMessage' => [ |
||
86 | 'template' => 'Custom incorrect input message.', |
||
87 | 'parameters' => [ |
||
88 | 'true' => 'YES', |
||
89 | ], |
||
90 | ], |
||
91 | 'message' => [ |
||
92 | 'template' => 'Custom message.', |
||
93 | 'parameters' => [ |
||
94 | 'true' => 'YES', |
||
95 | ], |
||
96 | ], |
||
97 | 'skipOnEmpty' => true, |
||
98 | 'skipOnError' => true, |
||
99 | ], |
||
215 |