Total Complexity | 43 |
Total Lines | 341 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like StatisticalTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use StatisticalTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
9 | class StatisticalTest extends TestCase |
||
10 | { |
||
11 | public function setUp() |
||
14 | } |
||
15 | |||
16 | /** |
||
17 | * @dataProvider providerAVEDEV |
||
18 | * |
||
19 | * @param mixed $expectedResult |
||
20 | */ |
||
21 | public function testAVEDEV($expectedResult, ...$args) |
||
22 | { |
||
23 | $result = Statistical::AVEDEV(...$args); |
||
24 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
25 | } |
||
26 | |||
27 | public function providerAVEDEV() |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @dataProvider providerAVERAGE |
||
34 | * |
||
35 | * @param mixed $expectedResult |
||
36 | */ |
||
37 | public function testAVERAGE($expectedResult, ...$args) |
||
38 | { |
||
39 | $result = Statistical::AVERAGE(...$args); |
||
40 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
41 | } |
||
42 | |||
43 | public function providerAVERAGE() |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @dataProvider providerAVERAGEA |
||
50 | * |
||
51 | * @param mixed $expectedResult |
||
52 | */ |
||
53 | public function testAVERAGEA($expectedResult, ...$args) |
||
54 | { |
||
55 | $result = Statistical::AVERAGEA(...$args); |
||
56 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
57 | } |
||
58 | |||
59 | public function providerAVERAGEA() |
||
60 | { |
||
61 | return require 'data/Calculation/Statistical/AVERAGEA.php'; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @dataProvider providerAVERAGEIF |
||
66 | * |
||
67 | * @param mixed $expectedResult |
||
68 | */ |
||
69 | public function testAVERAGEIF($expectedResult, ...$args) |
||
73 | } |
||
74 | |||
75 | public function providerAVERAGEIF() |
||
76 | { |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @dataProvider providerBETADIST |
||
82 | * |
||
83 | * @param mixed $expectedResult |
||
84 | */ |
||
85 | public function testBETADIST($expectedResult, ...$args) |
||
89 | } |
||
90 | |||
91 | public function providerBETADIST() |
||
92 | { |
||
93 | return require 'data/Calculation/Statistical/BETADIST.php'; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @dataProvider providerBETAINV |
||
98 | * |
||
99 | * @param mixed $expectedResult |
||
100 | */ |
||
101 | public function testBETAINV($expectedResult, ...$args) |
||
105 | } |
||
106 | |||
107 | public function providerBETAINV() |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @dataProvider providerBINOMDIST |
||
114 | * |
||
115 | * @param mixed $expectedResult |
||
116 | */ |
||
117 | public function testBINOMDIST($expectedResult, ...$args) |
||
118 | { |
||
119 | $result = Statistical::BINOMDIST(...$args); |
||
120 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
121 | } |
||
122 | |||
123 | public function providerBINOMDIST() |
||
124 | { |
||
125 | return require 'data/Calculation/Statistical/BINOMDIST.php'; |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * @dataProvider providerCHIDIST |
||
130 | * |
||
131 | * @param mixed $expectedResult |
||
132 | */ |
||
133 | public function testCHIDIST($expectedResult, ...$args) |
||
137 | } |
||
138 | |||
139 | public function providerCHIDIST() |
||
140 | { |
||
141 | return require 'data/Calculation/Statistical/CHIDIST.php'; |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * @dataProvider providerCHIINV |
||
146 | * |
||
147 | * @param mixed $expectedResult |
||
148 | */ |
||
149 | public function testCHIINV($expectedResult, ...$args) |
||
153 | } |
||
154 | |||
155 | public function providerCHIINV() |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * @dataProvider providerCONFIDENCE |
||
162 | * |
||
163 | * @param mixed $expectedResult |
||
164 | */ |
||
165 | public function testCONFIDENCE($expectedResult, ...$args) |
||
166 | { |
||
167 | $result = Statistical::CONFIDENCE(...$args); |
||
168 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
169 | } |
||
170 | |||
171 | public function providerCONFIDENCE() |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * @dataProvider providerCORREL |
||
178 | * |
||
179 | * @param mixed $expectedResult |
||
180 | */ |
||
181 | public function testCORREL($expectedResult, array $xargs, array $yargs) |
||
182 | { |
||
183 | $result = Statistical::CORREL($xargs, $yargs); |
||
184 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
185 | } |
||
186 | |||
187 | public function providerCORREL() |
||
188 | { |
||
189 | return require 'data/Calculation/Statistical/CORREL.php'; |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * @dataProvider providerCOUNTIF |
||
194 | * |
||
195 | * @param mixed $expectedResult |
||
196 | */ |
||
197 | public function testCOUNTIF($expectedResult, ...$args) |
||
198 | { |
||
199 | $result = Statistical::COUNTIF(...$args); |
||
200 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
201 | } |
||
202 | |||
203 | public function providerCOUNTIF() |
||
204 | { |
||
205 | return require 'data/Calculation/Statistical/COUNTIF.php'; |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * @dataProvider providerCOUNTIFS |
||
210 | * |
||
211 | * @param mixed $expectedResult |
||
212 | */ |
||
213 | public function testCOUNTIFS($expectedResult, ...$args) |
||
214 | { |
||
215 | $result = Statistical::COUNTIFS(...$args); |
||
216 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
217 | } |
||
218 | |||
219 | public function providerCOUNTIFS() |
||
222 | } |
||
223 | |||
224 | /** |
||
225 | * @dataProvider providerCOVAR |
||
226 | * |
||
227 | * @param mixed $expectedResult |
||
228 | */ |
||
229 | public function testCOVAR($expectedResult, ...$args) |
||
233 | } |
||
234 | |||
235 | public function providerCOVAR() |
||
238 | } |
||
239 | |||
240 | /** |
||
241 | * @dataProvider providerFORECAST |
||
242 | * |
||
243 | * @param mixed $expectedResult |
||
244 | */ |
||
245 | public function testFORECAST($expectedResult, ...$args) |
||
246 | { |
||
247 | $result = Statistical::FORECAST(...$args); |
||
248 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
249 | } |
||
250 | |||
251 | public function providerFORECAST() |
||
254 | } |
||
255 | |||
256 | /** |
||
257 | * @dataProvider providerINTERCEPT |
||
258 | * |
||
259 | * @param mixed $expectedResult |
||
260 | */ |
||
261 | public function testINTERCEPT($expectedResult, array $xargs, array $yargs) |
||
262 | { |
||
263 | $result = Statistical::INTERCEPT($xargs, $yargs); |
||
264 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
265 | } |
||
266 | |||
267 | public function providerINTERCEPT() |
||
268 | { |
||
269 | return require 'data/Calculation/Statistical/INTERCEPT.php'; |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * @dataProvider providerMAXIFS |
||
274 | * |
||
275 | * @param mixed $expectedResult |
||
276 | */ |
||
277 | public function testMAXIFS($expectedResult, ...$args) |
||
278 | { |
||
279 | $result = Statistical::MAXIFS(...$args); |
||
280 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
281 | } |
||
282 | |||
283 | public function providerMAXIFS() |
||
284 | { |
||
285 | return require 'data/Calculation/Statistical/MAXIFS.php'; |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * @dataProvider providerMINIFS |
||
290 | * |
||
291 | * @param mixed $expectedResult |
||
292 | */ |
||
293 | public function testMINIFS($expectedResult, ...$args) |
||
294 | { |
||
295 | $result = Statistical::MINIFS(...$args); |
||
296 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
297 | } |
||
298 | |||
299 | public function providerMINIFS() |
||
300 | { |
||
301 | return require 'data/Calculation/Statistical/MINIFS.php'; |
||
302 | } |
||
303 | |||
304 | /** |
||
305 | * @dataProvider providerRSQ |
||
306 | * |
||
307 | * @param mixed $expectedResult |
||
308 | */ |
||
309 | public function testRSQ($expectedResult, array $xargs, array $yargs) |
||
310 | { |
||
311 | $result = Statistical::RSQ($xargs, $yargs); |
||
312 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
313 | } |
||
314 | |||
315 | public function providerRSQ() |
||
318 | } |
||
319 | |||
320 | /** |
||
321 | * @dataProvider providerSLOPE |
||
322 | * |
||
323 | * @param mixed $expectedResult |
||
324 | */ |
||
325 | public function testSLOPE($expectedResult, array $xargs, array $yargs) |
||
326 | { |
||
327 | $result = Statistical::SLOPE($xargs, $yargs); |
||
328 | self::assertEquals($expectedResult, $result, '', 1E-12); |
||
329 | } |
||
330 | |||
331 | public function providerSLOPE() |
||
332 | { |
||
333 | return require 'data/Calculation/Statistical/SLOPE.php'; |
||
334 | } |
||
335 | |||
336 | /** |
||
337 | * @dataProvider providerSTEYX |
||
338 | * |
||
339 | * @param mixed $expectedResult |
||
340 | */ |
||
341 | public function testSTEYX($expectedResult, array $xargs, array $yargs) |
||
345 | } |
||
346 | |||
347 | public function providerSTEYX() |
||
348 | { |
||
349 | return require 'data/Calculation/Statistical/STEYX.php'; |
||
350 | } |
||
351 | } |
||
352 |