| Conditions | 6 |
| Paths | 8 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 3 | public static function fromNonWritableLocation($path) : self |
|
| 31 | { |
||
| 32 | 3 | $messages = []; |
|
| 33 | 3 | $destination = realpath($path); |
|
| 34 | |||
| 35 | 3 | if (! $destination) { |
|
| 36 | 1 | $messages[] = 'path does not exist'; |
|
| 37 | } |
||
| 38 | |||
| 39 | 3 | if ($destination && ! is_file($destination)) { |
|
| 40 | 2 | $messages[] = 'exists and is not a file'; |
|
| 41 | } |
||
| 42 | |||
| 43 | 3 | if ($destination && ! is_writable($destination)) { |
|
| 44 | 1 | $messages[] = 'is not writable'; |
|
| 45 | } |
||
| 46 | |||
| 47 | 3 | return new self(sprintf('Could not write to path "%s": %s', $path, implode(', ', $messages))); |
|
| 48 | } |
||
| 49 | } |
||
| 50 |