| Conditions | 4 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | 3 | public static function download($from, $to): bool |
|
| 30 | { |
||
| 31 | /** |
||
| 32 | * @var bool|resource $fromStream |
||
| 33 | */ |
||
| 34 | 3 | $fromStream = File::open($from); |
|
| 35 | |||
| 36 | 3 | if (!is_resource($fromStream)) |
|
| 37 | { |
||
| 38 | 1 | throw new NotFound\Path('Stream `' . $from . '` not found'); |
|
| 39 | } |
||
| 40 | |||
| 41 | 2 | if (!File::real($to) && !File::touch($to)) |
|
| 42 | { |
||
| 43 | 1 | throw new Exceptions\PermissionDenied('File `' . $to . '`'); |
|
| 44 | } |
||
| 45 | |||
| 46 | 1 | File::put($to, $fromStream); |
|
| 47 | |||
| 48 | 1 | return File::close($fromStream); |
|
| 49 | } |
||
| 50 | |||
| 101 |