| Conditions | 6 |
| Paths | 14 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function execute(Config $config, IO $io, Repository $repository, Config\Action $action): void |
||
| 28 | { |
||
| 29 | $pathToFolder = $action->getOptions()->get('pathSrc'); |
||
| 30 | $searchedFolder = $action->getOptions()->get('folderName'); |
||
| 31 | $path = glob((getcwd() . $pathToFolder)); |
||
| 32 | $errors = []; |
||
| 33 | foreach ($path as $folder) { |
||
| 34 | $folderName = $folder . $searchedFolder; |
||
| 35 | if (!is_dir($folderName)) { |
||
| 36 | $errors[] = '<error>Missing ' . $searchedFolder . ' folder in ' . basename($folder) . ' </error>'; |
||
| 37 | } |
||
| 38 | if (is_dir($folderName)) { |
||
| 39 | $filesInDir = array_diff(scandir($folderName), ['.', '..']); |
||
|
|
|||
| 40 | if (count($filesInDir) === 0) { |
||
| 41 | $errors[] = '<error>Empty ' . $searchedFolder . ' folder in ' . basename($folder) . ' </error>'; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 | if (empty($errors)) { |
||
| 46 | $io->write('<info>No errors found while checking for ' . $searchedFolder . ' files</info>'); |
||
| 47 | } else { |
||
| 48 | $io->writeError($errors); |
||
| 49 | throw new Exception('Please check if ' . $searchedFolder . ' folder is not missing and is not empty'); |
||
| 50 | } |
||
| 53 |