| Conditions | 6 |
| Paths | 6 |
| Total Lines | 31 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public function validate(): void |
||
| 16 | { |
||
| 17 | $assetPath = $_ENV['ASSET_PATH'] ?? ''; |
||
| 18 | if ($assetPath === '') { |
||
| 19 | throw new EnvironmentValidationException( |
||
| 20 | 'ASSET_PATH is not set in config' |
||
| 21 | ); |
||
| 22 | } |
||
| 23 | |||
| 24 | if (!is_writeable($assetPath)) { |
||
| 25 | throw new EnvironmentValidationException( |
||
| 26 | sprintf( |
||
| 27 | 'ASSET_PATH `%s` is not a valid writeable directory', |
||
| 28 | $assetPath |
||
| 29 | ) |
||
| 30 | ); |
||
| 31 | } |
||
| 32 | |||
| 33 | foreach (static::ASSET_SUB_FOLDERS as $folder) { |
||
| 34 | $path = sprintf('%s/%s', $assetPath, $folder); |
||
| 35 | |||
| 36 | if (!is_dir($path)) { |
||
| 37 | $result = mkdir( |
||
| 38 | $path, |
||
| 39 | static::PERMISSIONS, |
||
| 40 | true |
||
| 41 | ); |
||
| 42 | |||
| 43 | if ($result === false) { |
||
| 44 | throw new EnvironmentValidationException( |
||
| 45 | sprintf('Creation of folder `%s` failed', $path) |
||
| 46 | ); |
||
| 52 |