| Conditions | 1 |
| Paths | 1 |
| Total Lines | 97 |
| Code Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 50 | public function parseLineData() |
||
| 51 | { |
||
| 52 | return [ |
||
| 53 | [ |
||
| 54 | new CsvFormat([CsvFormat::OPTION_HEADER_ROW => 0]), |
||
| 55 | '"a","b",c,1,true,0.2,false,", enclosed","\\n \\r stuff",\\N', |
||
| 56 | [['a', 'b', 'c', '1', 'true', '0.2', 'false', ', enclosed', "n r stuff", null]], |
||
| 57 | ], |
||
| 58 | [ |
||
| 59 | new CsvFormat([ |
||
| 60 | CsvFormat::OPTION_DELIMITER => '|', |
||
| 61 | CsvFormat::OPTION_ESCAPE => '~', |
||
| 62 | CsvFormat::OPTION_QUOTE => '`', |
||
| 63 | CsvFormat::OPTION_NULL => 'null', |
||
| 64 | CsvFormat::OPTION_HEADER_ROW => 0, |
||
| 65 | CsvFormat::OPTION_DOUBLE_QUOTE => true, |
||
| 66 | ]), |
||
| 67 | '`string`|`other,thing`|some stuff|escaped ~\\n|``` all the `` quotes `|null', |
||
| 68 | [['string', 'other,thing', 'some stuff', 'escaped \n', '` all the ` quotes ', null]], |
||
| 69 | ], |
||
| 70 | [ |
||
| 71 | new CsvFormat([ |
||
| 72 | CsvFormat::OPTION_QUOTE => "\\", |
||
| 73 | CsvFormat::OPTION_DELIMITER => '|', |
||
| 74 | CsvFormat::OPTION_ESCAPE => "\\", |
||
| 75 | CsvFormat::OPTION_HEADER_ROW => 0, |
||
| 76 | ]), |
||
| 77 | 'a|b|c|d\\|e', |
||
| 78 | [['a', 'b', 'c', 'd|e']], |
||
| 79 | ], |
||
| 80 | [ |
||
| 81 | new CsvFormat([ |
||
| 82 | CsvFormat::OPTION_HEADER_ROW => 1, |
||
| 83 | CsvFormat::OPTION_DOUBLE_QUOTE => true, |
||
| 84 | ]), |
||
| 85 | file_get_contents(__DIR__ . '/../../../fixtures/csv_file.csv'), |
||
| 86 | [ |
||
| 87 | [ |
||
| 88 | 'id' => '0', |
||
| 89 | 'name' => 'my name', |
||
| 90 | 'things' => 'i like " quotes', |
||
| 91 | 'stuff' => 'question?', |
||
| 92 | ], |
||
| 93 | [ |
||
| 94 | 'id' => '1', |
||
| 95 | 'name' => 'your name', |
||
| 96 | 'things' => 'potatoes! ' . "\n" . 'and stuff', |
||
| 97 | 'stuff' => 'think', |
||
| 98 | ], |
||
| 99 | [ |
||
| 100 | 'id' => '2', |
||
| 101 | 'name' => 'your , nice', |
||
| 102 | 'things' => 'fish"', |
||
| 103 | 'stuff' => '","', |
||
| 104 | ], |
||
| 105 | ], |
||
| 106 | ], |
||
| 107 | [ |
||
| 108 | new CsvFormat([ |
||
| 109 | CsvFormat::OPTION_DATA_START => 1, |
||
| 110 | CsvFormat::OPTION_LIMIT => 2, |
||
| 111 | CsvFormat::OPTION_DOUBLE_QUOTE => true, |
||
| 112 | ]), |
||
| 113 | file_get_contents(__DIR__ . '/../../../fixtures/csv_file.csv'), |
||
| 114 | [ |
||
| 115 | ['id', 'name', 'things', 'stuff'], |
||
| 116 | ['0', 'my name', 'i like " quotes', 'question?'], |
||
| 117 | ], |
||
| 118 | ], |
||
| 119 | [ |
||
| 120 | new CsvFormat([ |
||
| 121 | CsvFormat::OPTION_DATA_START => 4, |
||
| 122 | CsvFormat::OPTION_DOUBLE_QUOTE => true, |
||
| 123 | ]), |
||
| 124 | file_get_contents(__DIR__ . '/../../../fixtures/csv_file.csv'), |
||
| 125 | [ |
||
| 126 | ['2', 'your , nice', 'fish"', '","'], |
||
| 127 | ], |
||
| 128 | ], |
||
| 129 | [ |
||
| 130 | new CsvFormat([ |
||
| 131 | CsvFormat::OPTION_HEADER_ROW => 1, |
||
| 132 | ]), |
||
| 133 | "\n" . '"1","2","3","4","5"', |
||
| 134 | [ |
||
| 135 | ['1', '2', '3', '4', '5'], |
||
| 136 | ], |
||
| 137 | ], |
||
| 138 | [ |
||
| 139 | new CsvFormat([ |
||
| 140 | CsvFormat::OPTION_BOM => Bom::BOM_UTF8, |
||
| 141 | ]), |
||
| 142 | Bom::BOM_UTF8 . '"text","here",",there"', |
||
| 143 | [['text', 'here', ',there']], |
||
| 144 | ], |
||
| 145 | ]; |
||
| 146 | } |
||
| 147 | |||
| 185 |