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 |
||
64 | public static function testDeletedColumns2(): void |
||
65 | { |
||
66 | $spreadsheet = new Spreadsheet(); |
||
67 | $sheet = $spreadsheet->getActiveSheet(); |
||
68 | $sheet->setTitle('Before'); |
||
69 | $sheet->getCell('A1')->setValue('a1'); |
||
70 | $sheet->getCell('J1')->setValue('j1'); |
||
71 | $sheet->getCell('K1')->setValue('will delete d-f'); |
||
72 | $sheet->getCell('C1')->setValue('c1-g1'); |
||
73 | $sheet->mergeCells('C1:G1'); |
||
74 | self::yellowBackground($sheet, 'C1'); |
||
75 | |||
76 | $sheet->getCell('A2')->setValue('a2'); |
||
77 | $sheet->getCell('J2')->setValue('j2'); |
||
78 | $sheet->getCell('B2')->setValue('b2-c2'); |
||
79 | $sheet->mergeCells('B2:C2'); |
||
80 | self::yellowBackground($sheet, 'B2'); |
||
81 | $sheet->getCell('G2')->setValue('g2-h2'); |
||
82 | $sheet->mergeCells('G2:H2'); |
||
83 | self::yellowBackground($sheet, 'G2', 'FF00FFFF'); |
||
84 | |||
85 | $sheet->getCell('A3')->setValue('a3'); |
||
86 | $sheet->getCell('J3')->setValue('j3'); |
||
87 | $sheet->getCell('D3')->setValue('d3-g3'); |
||
88 | $sheet->mergeCells('D3:G3'); |
||
89 | self::yellowBackground($sheet, 'D3'); |
||
90 | |||
91 | $sheet->getCell('A4')->setValue('a4'); |
||
92 | $sheet->getCell('J4')->setValue('j4'); |
||
93 | $sheet->getCell('B4')->setValue('b4-d4'); |
||
94 | $sheet->mergeCells('B4:D4'); |
||
95 | self::yellowBackground($sheet, 'B4'); |
||
96 | |||
97 | $sheet->getCell('A5')->setValue('a5'); |
||
98 | $sheet->getCell('J5')->setValue('j5'); |
||
99 | $sheet->getCell('D5')->setValue('d5-e5'); |
||
100 | $sheet->mergeCells('D5:E5'); |
||
101 | self::yellowBackground($sheet, 'D5'); |
||
102 | |||
103 | $sheet->removeColumn('D', 3); |
||
104 | $expected = [ |
||
105 | 'C1:D1', // was C1:G1, drop 3 inside cells |
||
106 | 'B2:C2', // was B2:C2, unaffected |
||
107 | 'D2:E2', // was G2:H2, move 3 columns left |
||
108 | //'D2:E2', // was D3:G3, start in delete range |
||
109 | 'B4:C4', // was B4:D4, truncated at start of delete range |
||
110 | //'D5:E5', // was D5:E5, start in delete range |
||
111 | ]; |
||
112 | self::assertSame($expected, array_keys($sheet->getMergeCells())); |
||
113 | |||
114 | $spreadsheet->disconnectWorksheets(); |
||
115 | } |
||
170 |