From 30ace290a83a155dce0e7fa242788dfe5c34b433 Mon Sep 17 00:00:00 2001 From: Quentin Gabriele Date: Sun, 3 Dec 2023 18:19:17 +0100 Subject: [PATCH] format --- src/FileDownloaders/FileDownloader.php | 4 ++-- src/Models/Media.php | 8 ++++---- tests/Feature/MediaTest.php | 2 +- tests/TestCase.php | 8 ++++---- tests/Unit/FileDownloaderTest.php | 2 -- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/FileDownloaders/FileDownloader.php b/src/FileDownloaders/FileDownloader.php index ba2e1a4..6fed6ea 100644 --- a/src/FileDownloaders/FileDownloader.php +++ b/src/FileDownloaders/FileDownloader.php @@ -7,7 +7,7 @@ class FileDownloader { - public static function getTemporaryFile(string $url, TemporaryDirectory $temporaryDirectory = null): string + public static function getTemporaryFile(string $url, TemporaryDirectory $temporaryDirectory = null): string { $context = stream_context_create([ 'http' => [ @@ -15,7 +15,7 @@ public static function getTemporaryFile(string $url, TemporaryDirectory $tempor ], ]); - if (!$stream = @fopen($url, 'r', false, $context)) { + if (! $stream = @fopen($url, 'r', false, $context)) { throw new Exception("Can't reach the url: {$url}"); } diff --git a/src/Models/Media.php b/src/Models/Media.php index e98007d..873acd7 100644 --- a/src/Models/Media.php +++ b/src/Models/Media.php @@ -121,7 +121,7 @@ public function getPath(string $conversion = null): ?string public function generateBasePath(string $conversion = null): string { if ($conversion) { - return "{$this->uuid}/generated_conversions/" . str_replace('.', '/', $this->getConversionKey($conversion)) . '/'; + return "{$this->uuid}/generated_conversions/".str_replace('.', '/', $this->getConversionKey($conversion)).'/'; } return "{$this->uuid}/"; @@ -192,7 +192,7 @@ public function storeFileFromHttpFile( $this->name = File::sanitizeFilename($name ?? File::name($file)); $this->file_name = "{$this->name}.{$this->extension}"; - $this->path = Str::finish($basePath ?? $this->generateBasePath(), '/') . $this->file_name; + $this->path = Str::finish($basePath ?? $this->generateBasePath(), '/').$this->file_name; $this->putFile($file, fileName: $this->file_name); @@ -201,7 +201,7 @@ public function storeFileFromHttpFile( return $this; } - function storeFileFromUrl( + public function storeFileFromUrl( string $url, string $collection_name = null, string $basePath = null, @@ -264,7 +264,7 @@ public function storeConversion( name: $name, extension: $extension, file_name: $file_name, - path: ($basePath ?? $this->generateBasePath($conversion)) . $file_name, + path: ($basePath ?? $this->generateBasePath($conversion)).$file_name, mime_type: $mime_type, type: $type, state: $state, diff --git a/tests/Feature/MediaTest.php b/tests/Feature/MediaTest.php index bfa8c24..e8c0c33 100644 --- a/tests/Feature/MediaTest.php +++ b/tests/Feature/MediaTest.php @@ -160,7 +160,7 @@ $media->storeFile( file: $this->dummy_pdf_url, disk: 'media', - name: "foo" + name: 'foo' ); expect($media->name)->toBe('foo'); diff --git a/tests/TestCase.php b/tests/TestCase.php index e88a538..09ba895 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -9,14 +9,14 @@ class TestCase extends Orchestra { - public $dummy_pdf_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"; + public $dummy_pdf_url = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'; protected function setUp(): void { parent::setUp(); Factory::guessFactoryNamesUsing( - fn (string $modelName) => 'Finller\\Media\\Database\\Factories\\' . class_basename($modelName) . 'Factory' + fn (string $modelName) => 'Finller\\Media\\Database\\Factories\\'.class_basename($modelName).'Factory' ); } @@ -31,9 +31,9 @@ public function getEnvironmentSetUp($app) { config()->set('database.default', 'testing'); - $migration = include __DIR__ . '/../database/migrations/1_create_media_table.php.stub'; + $migration = include __DIR__.'/../database/migrations/1_create_media_table.php.stub'; $migration->up(); - $migration = include __DIR__ . '/../database/migrations/2_add_columns_to_media_table.php.stub'; + $migration = include __DIR__.'/../database/migrations/2_add_columns_to_media_table.php.stub'; $migration->up(); $app['db']->connection()->getSchemaBuilder()->create('tests', function (Blueprint $table) { diff --git a/tests/Unit/FileDownloaderTest.php b/tests/Unit/FileDownloaderTest.php index bbf8bd0..29e5721 100644 --- a/tests/Unit/FileDownloaderTest.php +++ b/tests/Unit/FileDownloaderTest.php @@ -1,8 +1,6 @@