| Conditions | 2 |
| Paths | 2 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 1 | public function split($filePath): array |
|
| 28 | { |
||
| 29 | 1 | $files = []; |
|
| 30 | |||
| 31 | 1 | $xlsFilePath = realpath($filePath); |
|
| 32 | 1 | $xlsWorkSheet = IOFactory::load($filePath); |
|
| 33 | /** @var IWriter $csvWriter */ |
||
| 34 | 1 | $csvWriter = IOFactory::createWriter($xlsWorkSheet, 'Csv'); |
|
| 35 | 1 | foreach ($xlsWorkSheet->getWorksheetIterator() as $sheetIndex => $workSheetTab) { |
|
| 36 | 1 | $csvWriter->setSheetIndex($sheetIndex); |
|
|
|
|||
| 37 | |||
| 38 | 1 | $sheetName = strtolower($this->slugify->slugify($workSheetTab->getTitle())); |
|
| 39 | 1 | $filePath = sprintf( |
|
| 40 | 1 | '%s_%s.csv', |
|
| 41 | 1 | pathinfo($xlsFilePath, PATHINFO_DIRNAME).'/'.pathinfo($xlsFilePath, PATHINFO_FILENAME), |
|
| 42 | 1 | $sheetName |
|
| 43 | ); |
||
| 44 | |||
| 45 | 1 | $csvWriter->save($filePath); |
|
| 46 | |||
| 47 | 1 | $files[] = ['sheet_name' => $sheetName, 'filepath' => $filePath]; |
|
| 48 | } |
||
| 49 | |||
| 50 | 1 | return $files; |
|
| 51 | } |
||
| 53 |