Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 45 |
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 |
||
73 | { |
||
74 | $this->mightHaveException($expectedResult); |
||
75 | $sheet = $this->sheet; |
||
76 | $sheet->fromArray([[0], [1], [1], [2], [3], [5], [8], [13], [21], [34], [55], [89]], null, 'A1', true); |
||
77 | $maxCol = $sheet->getHighestColumn(); |
||
78 | $maxRow = $sheet->getHighestRow(); |
||
79 | $visibleRows = [ |
||
80 | '1' => false, |
||
81 | '2' => true, |
||
82 | '3' => false, |
||
83 | '4' => true, |
||
84 | '5' => false, |
||
85 | '6' => false, |
||
86 | '7' => false, |
||
87 | '8' => true, |
||
88 | '9' => false, |
||
89 | '10' => true, |
||
90 | '11' => true, |
||
91 | '12' => false, |
||
92 | ]; |
||
93 | foreach ($visibleRows as $row => $visible) { |
||
94 | $sheet->getRowDimension($row)->setVisible($visible); |
||
95 | } |
||
96 | $sheet->getCell('D2')->setValue("=SUBTOTAL($type, A1:$maxCol$maxRow)"); |
||
97 | $result = $sheet->getCell('D2')->getCalculatedValue(); |
||
98 | self::assertEqualsWithDelta($expectedResult, $result, 1E-12); |
||
99 | } |
||
100 | |||
101 | public function providerSUBTOTALHIDDEN() |
||
102 | { |
||
103 | return require 'tests/data/Calculation/MathTrig/SUBTOTALHIDDEN.php'; |
||
104 | } |
||
105 | |||
106 | public function testSubtotalNested(): void |
||
107 | { |
||
108 | $sheet = $this->sheet; |
||
109 | $sheet->fromArray( |
||
110 | [ |
||
111 | [123], |
||
112 | [234], |
||
113 | ['=SUBTOTAL(1,A1:A2)'], |
||
114 | ['=ROMAN(SUBTOTAL(1, A1:A2))'], |
||
115 | ['This is text containing "=" and "SUBTOTAL("'], |
||
116 | ['=AGGREGATE(1, 0, A1:A2)'], |
||
117 | ['=SUM(2, 3)'], |
||
118 | ], |
||
119 | null, |
||
120 | 'A1', |
||
121 | true |
||
122 | ); |
||
123 | $maxCol = $sheet->getHighestColumn(); |
||
124 | $maxRow = $sheet->getHighestRow(); |
||
129 |