| 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 |
||
| 27 | public function validate(): void |
||
| 28 | { |
||
| 29 | $assetPath = $this->configProvider->getAssetPath(); |
||
| 30 | if ($assetPath === '') { |
||
| 31 | throw new EnvironmentValidationException( |
||
| 32 | 'ASSET_PATH is not set in config' |
||
| 33 | ); |
||
| 34 | } |
||
| 35 | |||
| 36 | if (!is_writable($assetPath)) { |
||
| 37 | throw new EnvironmentValidationException( |
||
| 38 | sprintf( |
||
| 39 | 'ASSET_PATH `%s` is not a valid writeable directory', |
||
| 40 | $assetPath |
||
| 41 | ) |
||
| 42 | ); |
||
| 43 | } |
||
| 44 | |||
| 45 | foreach (self::ASSET_SUB_FOLDERS as $folder) { |
||
| 46 | $path = sprintf('%s/%s', $assetPath, $folder); |
||
| 47 | |||
| 48 | if (!is_dir($path)) { |
||
| 49 | $result = mkdir( |
||
| 50 | $path, |
||
| 51 | self::PERMISSIONS, |
||
| 52 | true |
||
| 53 | ); |
||
| 54 | |||
| 55 | if (!$result) { |
||
| 56 | throw new EnvironmentValidationException( |
||
| 57 | sprintf('Creation of folder `%s` failed', $path) |
||
| 58 | ); |
||
| 64 |