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