| Conditions | 5 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public static function ensureFileIsWritable(string $filePath): void |
||
| 32 | { |
||
| 33 | if ('' === $filePath) { |
||
| 34 | throw new InvalidArgumentException('Path cannot be empty'); |
||
| 35 | } |
||
| 36 | |||
| 37 | if (\is_dir($filePath)) { |
||
| 38 | throw new InvalidArgumentException('Path cannot be a folder'); |
||
| 39 | } |
||
| 40 | |||
| 41 | if (!\is_file($filePath)) { |
||
| 42 | (new Filesystem())->mkdir(\dirname($filePath)); |
||
| 43 | |||
| 44 | return; |
||
| 45 | } |
||
| 46 | |||
| 47 | if (!\is_writable($filePath)) { |
||
| 48 | throw new InvalidArgumentException('File is not writable'); |
||
| 49 | } |
||
| 52 |