From 4dd3c2502b0cdd4980266e2567d0b59a01f85d1f Mon Sep 17 00:00:00 2001
From: Quentin Gabriele <quentin.gabriele@gmail.com>
Date: Sat, 12 Oct 2024 23:37:25 +0200
Subject: [PATCH] cleaning

---
 composer.json                          |  12 +-
 src/Traits/InteractsWithMediaFiles.php | 192 -------------------------
 2 files changed, 6 insertions(+), 198 deletions(-)
 delete mode 100644 src/Traits/InteractsWithMediaFiles.php

diff --git a/composer.json b/composer.json
index 1498a12..ae68805 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
     ],
     "require": {
         "php": "^8.1",
-        "illuminate/contracts": "^10.0|^11.0",
+        "illuminate/contracts": "^11.0",
         "maennchen/zipstream-php": "^3.1",
         "pbmedia/laravel-ffmpeg": "^8.3",
         "spatie/image": "^3.0.0",
@@ -26,12 +26,12 @@
     },
     "require-dev": {
         "laravel/pint": "^1.0",
-        "nunomaduro/collision": "^7.8|^8.1",
+        "nunomaduro/collision": "^8.1",
         "larastan/larastan": "^2.0.1",
-        "orchestra/testbench": "^8.8|^9.0",
-        "pestphp/pest": "^2.0",
-        "pestphp/pest-plugin-arch": "^2.0",
-        "pestphp/pest-plugin-laravel": "^2.0",
+        "orchestra/testbench": "^9.0",
+        "pestphp/pest": "^3.0",
+        "pestphp/pest-plugin-arch": "^3.0",
+        "pestphp/pest-plugin-laravel": "^3.0",
         "phpstan/extension-installer": "^1.1",
         "phpstan/phpstan-deprecation-rules": "^1.0",
         "phpstan/phpstan-phpunit": "^1.0"
diff --git a/src/Traits/InteractsWithMediaFiles.php b/src/Traits/InteractsWithMediaFiles.php
deleted file mode 100644
index 1d8ed4a..0000000
--- a/src/Traits/InteractsWithMediaFiles.php
+++ /dev/null
@@ -1,192 +0,0 @@
-<?php
-
-namespace Elegantly\Media\Traits;
-
-use Carbon\CarbonInterval;
-use Elegantly\Media\FileDownloaders\FileDownloader;
-use Elegantly\Media\Helpers\File;
-use Exception;
-use Illuminate\Contracts\Filesystem\Filesystem;
-use Illuminate\Http\File as HttpFile;
-use Illuminate\Http\UploadedFile;
-use Illuminate\Support\Facades\File as SupportFile;
-use Illuminate\Support\Facades\Storage;
-use Illuminate\Support\Number;
-use Spatie\TemporaryDirectory\TemporaryDirectory;
-
-/**
- * @property ?string $disk
- * @property ?string $path
- * @property ?int $size The filesize in bytes
- * @property ?float $duration in miliseconds
- */
-trait InteractsWithMediaFiles
-{
-    public function getDisk(): ?Filesystem
-    {
-        if (! $this->disk) {
-            return null;
-        }
-
-        return Storage::disk($this->disk);
-    }
-
-    public function getUrl(): ?string
-    {
-        if (! $this->path) {
-            return null;
-        }
-
-        return $this->getDisk()?->url($this->path);
-    }
-
-    public function getTemporaryUrl(
-        \DateTimeInterface $expiration,
-        array $options = []
-    ): ?string {
-        if (! $this->path) {
-            return null;
-        }
-
-        // @phpstan-ignore-next-line
-        return $this->getDisk()?->temporaryUrl($this->path, $expiration, $options);
-    }
-
-    /**
-     * @return null|resource
-     */
-    public function readStream()
-    {
-        return $this->getDisk()?->readStream($this->path);
-    }
-
-    /**
-     * @param  string  $path  including the file name
-     */
-    public function copyFileLocallyTo(string $path): ?string
-    {
-        if (! $this->path) {
-            return null;
-        }
-
-        $storage = Storage::build([
-            'driver' => 'local',
-            'root' => SupportFile::dirname($path),
-        ]);
-
-        $storage->put(
-            SupportFile::basename($path),
-            $this->readStream()
-        );
-
-        return $path;
-    }
-
-    public function makeTemporaryFileCopy(?TemporaryDirectory $temporaryDirectory = null): string|false
-    {
-        $temporaryDirectory ??= (new TemporaryDirectory)
-            ->location(storage_path('media-tmp'))
-            ->deleteWhenDestroyed()
-            ->create();
-
-        $path = $temporaryDirectory->path($this->file_name);
-
-        $this->copyFileLocallyTo($path);
-
-        return $path;
-    }
-
-    public function getDirname(): ?string
-    {
-        if (! $this->path) {
-            return null;
-        }
-
-        return SupportFile::dirname($this->path);
-    }
-
-    /**
-     * Put a file in the same directory than the main file
-     */
-    public function putFile(
-        string|UploadedFile|HttpFile $file,
-        ?string $name = null,
-        ?string $fileName = null,
-    ): string {
-
-        if (is_string($file) && filter_var($file, FILTER_VALIDATE_URL)) {
-            $file = new HttpFile(FileDownloader::getTemporaryFile($file));
-        } elseif (is_string($file)) {
-            $file = new HttpFile($file);
-        }
-
-        $fileName ??= File::extractFilename($file, $name);
-
-        $path = $this->getDisk()?->putFileAs(
-            $this->getDirname(),
-            $file,
-            $fileName
-        );
-
-        if (! $path) {
-            throw new Exception('['.static::class.']'."Putting the file {$fileName} to the instance failed");
-        }
-
-        return $path;
-    }
-
-    public function copyFileTo(
-        string $disk,
-        string $path
-    ): static {
-
-        $filesystem = Storage::disk($disk);
-
-        $filesystem->writeStream(
-            $path,
-            $this->readStream()
-        );
-
-        return $this;
-    }
-
-    public function deleteDirectory(): bool
-    {
-        if (! $this->path) {
-            return true;
-        }
-
-        return $this->getDisk()?->deleteDirectory($this->getDirname());
-    }
-
-    public function deleteFile(): bool
-    {
-        if (! $this->path) {
-            return true;
-        }
-
-        return $this->getDisk()?->delete($this->path);
-    }
-
-    public function humanReadableSize(int $precision = 0, ?int $maxPrecision = null): ?string
-    {
-        if (! $this->size) {
-            return null;
-        }
-
-        return Number::fileSize($this->size, $precision, $maxPrecision);
-    }
-
-    public function humanReadableDuration(
-        ?int $syntax = null,
-        ?bool $short = false,
-        ?int $parts = -1,
-        ?int $options = null
-    ): ?string {
-        if (! $this->duration) {
-            return null;
-        }
-
-        return CarbonInterval::milliseconds($this->duration)->forHumans($syntax, $short, $parts, $options);
-    }
-}