Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 44 |
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 |
||
15 | public function testXmlSpace(): void |
||
16 | { |
||
17 | $spreadsheet = new Spreadsheet(); |
||
18 | $sheet = $spreadsheet->getActiveSheet(); |
||
19 | $string = ' Ye&ar '; |
||
20 | $trimString = trim($string); |
||
21 | $sheet->getCell('A1')->setValue($string); |
||
22 | $sheet->getCell('A2')->setValueExplicit($string, DataType::TYPE_INLINE); |
||
23 | $sheet->getCell('B1')->setValue($trimString); |
||
24 | $sheet->getCell('B2')->setValueExplicit($trimString, DataType::TYPE_INLINE); |
||
25 | $writer = new XlsxWriter($spreadsheet); |
||
26 | |||
27 | $writer->createStyleDictionaries(); |
||
28 | $writerStyle = new XlsxWriter\Style($writer); |
||
29 | $data = $writerStyle->writeStyles($spreadsheet); |
||
30 | self::assertStringContainsString( |
||
31 | '<styleSheet', |
||
32 | $data |
||
33 | ); |
||
34 | self::assertStringNotContainsString( |
||
35 | 'xml:space', |
||
36 | $data |
||
37 | ); |
||
38 | |||
39 | $writerWorkbook = new XlsxWriter\Workbook($writer); |
||
40 | $data = $writerWorkbook->writeWorkbook($spreadsheet); |
||
41 | self::assertStringContainsString( |
||
42 | '<workbook', |
||
43 | $data |
||
44 | ); |
||
45 | self::assertStringNotContainsString( |
||
46 | 'xml:space', |
||
47 | $data |
||
48 | ); |
||
49 | |||
50 | $stringTable = $writer->createStringTable(); |
||
51 | $writerStringTable = new XlsxWriter\StringTable($writer); |
||
52 | $data = $writerStringTable->writeStringTable($stringTable); |
||
53 | self::assertStringContainsString( |
||
54 | '<si><t xml:space="preserve"> Ye&ar </t></si>', |
||
55 | $data |
||
56 | ); |
||
57 | self::assertStringContainsString( |
||
58 | '<si><t>Ye&ar</t></si>', |
||
59 | $data |
||
60 | ); |
||
61 | |||
62 | $writerWorksheet = new XlsxWriter\Worksheet($writer); |
||
63 | $data = $writerWorksheet->writeWorksheet($sheet, []); |
||
64 | self::assertStringContainsString( |
||
65 | '<c r="A2" t="inlineStr"><is><t xml:space="preserve"> Ye&ar </t></is></c>', |
||
66 | $data |
||
67 | ); |
||
68 | self::assertStringContainsString( |
||
69 | '<c r="B2" t="inlineStr"><is><t>Ye&ar</t></is></c>', |
||
70 | $data |
||
71 | ); |
||
72 | |||
73 | $spreadsheet->disconnectWorksheets(); |
||
74 | } |
||
110 |