| Total Complexity | 10 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | class File |
||
| 7 | { |
||
| 8 | private string $path; |
||
| 9 | private Disk $diskInstance; |
||
| 10 | |||
| 11 | |||
| 12 | public function __construct(string $path, ?string $disk = null) |
||
| 13 | { |
||
| 14 | $this->path = $path; |
||
| 15 | $this->diskInstance = Disk::make($disk); |
||
| 16 | } |
||
| 17 | |||
| 18 | public function __destruct() |
||
| 19 | { |
||
| 20 | $this->cleanup(); |
||
| 21 | } |
||
| 22 | |||
| 23 | public static function make(string $path, ?string $disk = null): self |
||
| 24 | { |
||
| 25 | return new static($path, $disk); |
||
| 26 | } |
||
| 27 | |||
| 28 | |||
| 29 | public function getDisk(): Disk |
||
| 32 | } |
||
| 33 | |||
| 34 | public function getPath(): string |
||
| 37 | } |
||
| 38 | |||
| 39 | public function getLocalPath(): string |
||
| 40 | { |
||
| 41 | $path = $this->getPath(); |
||
| 42 | $disk = $this->getDisk()->getAdapter(); |
||
| 43 | |||
| 44 | if ($disk) { |
||
|
|
|||
| 45 | if ($this->getDisk()->isLocalDisk()) { |
||
| 46 | return $disk->path($path); |
||
| 47 | } |
||
| 48 | |||
| 49 | $temporaryDisk = $this->getDisk()->getTemporaryDisk(); |
||
| 50 | |||
| 51 | if (!$temporaryDisk->exists($path)) { |
||
| 52 | $temporaryDisk->writeStream($path, $disk->readStream($path)); |
||
| 53 | } |
||
| 54 | |||
| 55 | return $temporaryDisk->path($path); |
||
| 56 | } |
||
| 57 | |||
| 58 | return $path; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function cleanup(): self |
||
| 66 | } |
||
| 67 | } |
||
| 68 |