Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 52 |
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 |
||
102 | private function validationAssertions(): array |
||
103 | { |
||
104 | return [ |
||
105 | // Numeric tests |
||
106 | 'Integer between 2 and 5: x' => [false, 'F1', 'x'], |
||
107 | 'Integer between 2 and 5: 3.1' => [false, 'F1', 3.1], |
||
108 | 'Integer between 2 and 5: 3' => [true, 'F1', 3], |
||
109 | 'Integer between 2 and 5: 1' => [false, 'F1', 1], |
||
110 | 'Integer between 2 and 5: 7' => [false, 'F1', 7], |
||
111 | 'Float between 2 and 5: x' => [false, 'G1', 'x'], |
||
112 | 'Float between 2 and 5: 3.1' => [true, 'G1', 3.1], |
||
113 | 'Float between 2 and 5: 3' => [true, 'G1', 3], |
||
114 | 'Float between 2 and 5: 1' => [false, 'G1', 1], |
||
115 | 'Float between 2 and 5: 7' => [false, 'G1', 7], |
||
116 | 'Integer not between -5 and 5: 3' => [false, 'F2', 3], |
||
117 | 'Integer not between -5 and 5: -1' => [false, 'F2', -1], |
||
118 | 'Integer not between -5 and 5: 7' => [true, 'F2', 7], |
||
119 | 'Any integer except 7: -1' => [true, 'F3', -1], |
||
120 | 'Any integer except 7: 7' => [false, 'F3', 7], |
||
121 | 'Only -3: -1' => [false, 'F4', -1], |
||
122 | 'Only -3: -3' => [true, 'F4', -3], |
||
123 | 'Integer less than 8: 8' => [false, 'F5', 8], |
||
124 | 'Integer less than 8: 7' => [true, 'F5', 7], |
||
125 | 'Integer less than 8: 9' => [false, 'F5', 9], |
||
126 | 'Integer less than or equal 12: 12' => [true, 'F6', 12], |
||
127 | 'Integer less than or equal 12: 7' => [true, 'F6', 7], |
||
128 | 'Integer less than or equal 12: 13' => [false, 'F6', 13], |
||
129 | 'Integer greater than or equal -6: -6' => [true, 'F7', -6], |
||
130 | 'Integer greater than or equal -6: -7' => [false, 'F7', -7], |
||
131 | 'Integer greater than or equal -6: -5' => [true, 'F7', -5], |
||
132 | 'Integer greater than 5: 5' => [false, 'F8', 5], |
||
133 | 'Integer greater than 5: 6' => [true, 'F8', 6], |
||
134 | 'Integer greater than 5: 3' => [false, 'F8', 3], |
||
135 | // Text tests |
||
136 | 'a,b,c,d,e: a' => [true, 'C4', 'a'], |
||
137 | 'a,b,c,d,e: c' => [true, 'C4', 'c'], |
||
138 | 'a,b,c,d,e: e' => [true, 'C4', 'e'], |
||
139 | 'a,b,c,d,e: x' => [false, 'C4', 'x'], |
||
140 | 'a,b,c,d,e: aa' => [false, 'C4', 'aa'], |
||
141 | 'less than 8 characters: abcdefg' => [true, 'C3', 'abcdefg'], |
||
142 | 'less than 8 characters: abcdefgh' => [false, 'C3', 'abcdefgh'], |
||
143 | 'texts in e1 to e5: ccc' => [true, 'D2', 'ccc'], |
||
144 | 'texts in e1 to e5: ffffff' => [false, 'D2', 'ffffff'], |
||
145 | 'date from 20230101: 20221231' => [false, 'C1', Date::convertIsoDate('20221231')], |
||
146 | 'date from 20230101: 20230101' => [true, 'C1', Date::convertIsoDate('20230101')], |
||
147 | 'date from 20230101: 20240507' => [true, 'C1', Date::convertIsoDate('20240507')], |
||
148 | 'date from 20230101: 20240507 10:00:00' => [true, 'C1', Date::convertIsoDate('20240507 10:00:00')], |
||
149 | 'time from 12:00-14:00: 2023-01-01 13:00:00' => [false, 'C2', Date::convertIsoDate('2023-01-01 13:00:00')], |
||
150 | 'time from 8:00-14:00: 13:00' => [true, 'C2', Date::convertIsoDate('13:00')], |
||
151 | 'time from 8:00-14:00: 07:00:00' => [false, 'C2', Date::convertIsoDate('07:00:00')], |
||
152 | 'time from 8:00-14:00: 15:00:00' => [false, 'C2', Date::convertIsoDate('15:00:00')], |
||
153 | 'time from 8:00-14:00: 1:13 am' => [false, 'C2', Date::convertIsoDate('1:13 am')], |
||
154 | 'time from 8:00-14:00: 1:13 pm' => [true, 'C2', Date::convertIsoDate('1:13 pm')], |
||
155 | 'time from 8:00-14:00: 9:13' => [true, 'C2', Date::convertIsoDate('9:13')], |
||
156 | 'time from 8:00-14:00: 9:13 am' => [true, 'C2', Date::convertIsoDate('9:13 am')], |
||
157 | 'time from 8:00-14:00: 9:13 pm' => [false, 'C2', Date::convertIsoDate('9:13 pm')], |
||
158 | ]; |
||
161 |