Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
48 | public function parseLineData() |
||
49 | { |
||
50 | return [ |
||
51 | [ |
||
52 | new CsvFormat([CsvFormat::OPTION_HEADERS => 0]), |
||
53 | '"a","b",c,1,true,0.2,false,", enclosed","\\n \\r stuff",\\N', |
||
54 | [['a', 'b', 'c', '1', 'true', '0.2', 'false', ', enclosed', "n r stuff", null]], |
||
55 | ], |
||
56 | [ |
||
57 | new CsvFormat([ |
||
58 | CsvFormat::OPTION_DELIMITER => '|', |
||
59 | CsvFormat::OPTION_ESCAPE => '~', |
||
60 | CsvFormat::OPTION_QUOTE_CHARACTER => '`', |
||
61 | CsvFormat::OPTION_NULL_OUTPUT => 'null', |
||
62 | CsvFormat::OPTION_HEADERS => 0, |
||
63 | CsvFormat::OPTION_DOUBLE_QUOTE => true, |
||
64 | ]), |
||
65 | '`string`|`other,thing`|some stuff|escaped ~\\n|``` all the `` quotes `|null', |
||
66 | [['string', 'other,thing', 'some stuff', 'escaped \n', '` all the ` quotes ', null]], |
||
67 | ], |
||
68 | [ |
||
69 | new CsvFormat([ |
||
70 | CsvFormat::OPTION_QUOTE_CHARACTER => "\\", |
||
71 | CsvFormat::OPTION_DELIMITER => '|', |
||
72 | CsvFormat::OPTION_ESCAPE => "\\", |
||
73 | CsvFormat::OPTION_HEADERS => 0, |
||
74 | ]), |
||
75 | 'a|b|c|d\\|e', |
||
76 | [['a', 'b', 'c', 'd|e']], |
||
77 | ], |
||
78 | [ |
||
79 | new CsvFormat([ |
||
80 | CsvFormat::OPTION_HEADERS => 1, |
||
81 | CsvFormat::OPTION_DOUBLE_QUOTE => true, |
||
82 | ]), |
||
83 | file_get_contents(__DIR__ . '/../../../fixtures/csv_file.csv'), |
||
84 | [ |
||
85 | ['0', 'my name', 'i like " quotes', 'question?'], |
||
86 | ['1', 'your name', 'potatoes! ' . "\n" . 'and stuff', 'think'], |
||
87 | ['2', 'your , nice', 'fish"', '","'], |
||
88 | ], |
||
89 | ], |
||
90 | [ |
||
91 | new CsvFormat([ |
||
92 | CsvFormat::OPTION_HEADERS => 0, |
||
93 | CsvFormat::OPTION_LIMIT => 2, |
||
94 | CsvFormat::OPTION_DOUBLE_QUOTE => true, |
||
95 | ]), |
||
96 | file_get_contents(__DIR__ . '/../../../fixtures/csv_file.csv'), |
||
97 | [ |
||
98 | ['id', 'name', 'things', 'stuff'], |
||
99 | ['0', 'my name', 'i like " quotes', 'question?'], |
||
100 | ], |
||
101 | ], |
||
102 | ]; |
||
103 | } |
||
104 | } |
||
105 |