| Conditions | 7 |
| Paths | 7 |
| Total Lines | 32 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 33 | public function getAllScripts(): array |
||
| 34 | { |
||
| 35 | $scripts = []; |
||
| 36 | |||
| 37 | foreach ($this->scriptPaths as $pathNamespace => $path) { |
||
| 38 | if (!is_dir($path)) { |
||
| 39 | throw new ScriptPathNotValidException("The given script path: '{$path}' is not a valid directory"); |
||
| 40 | } |
||
| 41 | |||
| 42 | foreach (scandir($path) as $fileName) { |
||
| 43 | $scriptNamespace = null; |
||
| 44 | |||
| 45 | if (strpos($fileName, '.') === 0) { |
||
| 46 | continue; |
||
| 47 | } |
||
| 48 | |||
| 49 | $extension = pathinfo($fileName, PATHINFO_EXTENSION); |
||
| 50 | |||
| 51 | if (!in_array($extension, self::VALID_EXTENSIONS)) { |
||
| 52 | continue; |
||
| 53 | } |
||
| 54 | |||
| 55 | if (!is_numeric($pathNamespace)) { |
||
| 56 | $scriptNamespace = $pathNamespace; |
||
| 57 | } |
||
| 58 | |||
| 59 | $scripts[] = new Script($path, $fileName, $scriptNamespace); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | return $scripts; |
||
| 64 | } |
||
| 65 | |||
| 82 |