Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 40 |
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 |
||
117 | public static function testDeletedRows2(): void |
||
118 | { |
||
119 | $spreadsheet = new Spreadsheet(); |
||
120 | $sheet = $spreadsheet->getActiveSheet(); |
||
121 | $sheet->setTitle('Before'); |
||
122 | $sheet->getCell('A1')->setValue('a1'); |
||
123 | $sheet->getCell('A10')->setValue('a10'); |
||
124 | $sheet->getCell('A11')->setValue('will delete 4-6'); |
||
125 | $sheet->getCell('A3')->setValue('a3-a7'); |
||
126 | $sheet->mergeCells('A3:A7'); |
||
127 | self::yellowBackground($sheet, 'A3'); |
||
128 | |||
129 | $sheet->getCell('B1')->setValue('b1'); |
||
130 | $sheet->getCell('B10')->setValue('b10'); |
||
131 | $sheet->getCell('B2')->setValue('b2-b3'); |
||
132 | $sheet->mergeCells('B2:B3'); |
||
133 | self::yellowBackground($sheet, 'B2'); |
||
134 | $sheet->getCell('B7')->setValue('b7-b8'); |
||
135 | $sheet->mergeCells('B7:B8'); |
||
136 | self::yellowBackground($sheet, 'B7', 'FF00FFFF'); |
||
137 | |||
138 | $sheet->getCell('C1')->setValue('c1'); |
||
139 | $sheet->getCell('C10')->setValue('c10'); |
||
140 | $sheet->getCell('C4')->setValue('c4-c7'); |
||
141 | $sheet->mergeCells('C4:C7'); |
||
142 | self::yellowBackground($sheet, 'C4'); |
||
143 | |||
144 | $sheet->getCell('D1')->setValue('d1'); |
||
145 | $sheet->getCell('D10')->setValue('d10'); |
||
146 | $sheet->getCell('D2')->setValue('d2-d4'); |
||
147 | $sheet->mergeCells('D2:D4'); |
||
148 | self::yellowBackground($sheet, 'd2'); |
||
149 | |||
150 | $sheet->getCell('E1')->setValue('e1'); |
||
151 | $sheet->getCell('E10')->setValue('e10'); |
||
152 | $sheet->getCell('E4')->setValue('e4-e5'); |
||
153 | $sheet->mergeCells('E4:E5'); |
||
154 | self::yellowBackground($sheet, 'E4'); |
||
155 | |||
156 | $sheet->removeRow(4, 3); |
||
157 | $expected = [ |
||
158 | 'A3:A4', // was A3:A7, drop 3 inside cells |
||
159 | 'B2:B3', // was B2:B3, unaffected |
||
160 | 'B4:B5', // was B7:B8, move 3 columns up |
||
161 | //'C4:C7', // was C4:C7, start in delete range |
||
162 | 'D2:D3', // was D2:D4, truncated at start of delete range |
||
163 | //'E4:E5', // was E4:E5, start in delete range |
||
164 | ]; |
||
165 | self::assertSame($expected, array_keys($sheet->getMergeCells())); |
||
166 | |||
167 | $spreadsheet->disconnectWorksheets(); |
||
168 | } |
||
170 |