| Conditions | 5 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5.3256 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | 4 | public function convert(string $source, string $destination): void |
|
| 32 | { |
||
| 33 | 4 | if ('' === $destination) { |
|
| 34 | throw new RuntimeException('Destination is empty'); |
||
| 35 | } |
||
| 36 | 4 | if (! is_dir($destination) || ! is_writable($destination)) { |
|
| 37 | throw new RuntimeException("Destination directory $destination is not a directory or is not writable"); |
||
| 38 | } |
||
| 39 | |||
| 40 | 4 | $command = escapeshellarg($this->xlsx2csvPath()) . ' ' . implode(' ', array_map('escapeshellarg', [ |
|
| 41 | 4 | '--ignoreempty', |
|
| 42 | 4 | '--escape', |
|
| 43 | 4 | '--all', |
|
| 44 | 4 | '--dateformat', |
|
| 45 | 4 | '%Y-%m-%d', |
|
| 46 | 4 | $source, |
|
| 47 | 4 | $destination, |
|
| 48 | ])); |
||
| 49 | |||
| 50 | 4 | $execution = ShellExec::run($command); |
|
| 51 | 4 | if (0 !== $execution->exitStatus()) { |
|
| 52 | throw new RuntimeException( |
||
| 53 | "Execution of xlsx2csv convertion return a non zero status code [{$execution->exitStatus()}]" |
||
| 54 | ); |
||
| 58 |