Conditions | 3 |
Paths | 3 |
Total Lines | 53 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
16 | public static function testSumData(): void |
||
17 | { |
||
18 | $filename = 'tests/data/Reader/XLS/pr607.sum_data.xls'; |
||
19 | $reader = new XlsReader(); |
||
20 | $spreadsheet = $reader->load($filename); |
||
21 | |||
22 | $tests = [ |
||
23 | 'Test' => [ |
||
24 | 'A1' => 1, |
||
25 | 'A2' => 2, |
||
26 | 'A3' => 3, |
||
27 | 'A4' => 4, |
||
28 | 'A5' => 5, |
||
29 | 'A6' => 6, |
||
30 | 'A7' => 7, |
||
31 | 'A8' => 8, |
||
32 | 'A9' => 9, |
||
33 | 'A10' => 10, |
||
34 | |||
35 | 'B1' => 3, |
||
36 | 'B2' => 4, |
||
37 | 'B3' => 5, |
||
38 | 'B4' => 6, |
||
39 | 'B5' => 7, |
||
40 | 'B6' => 8, |
||
41 | 'B7' => 9, |
||
42 | 'B8' => 10, |
||
43 | 'B9' => 11, |
||
44 | 'B10' => 12, |
||
45 | |||
46 | 'C1' => 4, |
||
47 | 'C2' => 6, |
||
48 | 'C3' => 8, |
||
49 | 'C4' => 10, |
||
50 | 'C5' => 12, |
||
51 | 'C6' => 14, |
||
52 | 'C7' => 16, |
||
53 | 'C8' => 18, |
||
54 | 'C9' => 20, |
||
55 | 'C10' => 22, |
||
56 | ], |
||
57 | ]; |
||
58 | |||
59 | foreach ($tests as $sheetName => $testsForSheet) { |
||
60 | $sheet = $spreadsheet->getSheetByName($sheetName); |
||
61 | self::assertNotNull($sheet); |
||
62 | |||
63 | foreach ($testsForSheet as $cellCoordinate => $result) { |
||
64 | $calculatedValue = $sheet->getCell($cellCoordinate)->getCalculatedValue(); |
||
65 | self::assertSame($result, $calculatedValue, "cell $cellCoordinate"); |
||
66 | } |
||
67 | } |
||
68 | $spreadsheet->disconnectWorksheets(); |
||
69 | } |
||
71 |