Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Dec 3, 2023
1 parent c2293ab commit 30ace29
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/FileDownloaders/FileDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

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' => [
'header' => 'User-Agent: Finller laravel-media package',
],
]);

if (!$stream = @fopen($url, 'r', false, $context)) {
if (! $stream = @fopen($url, 'r', false, $context)) {
throw new Exception("Can't reach the url: {$url}");
}

Expand Down
8 changes: 4 additions & 4 deletions src/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}/";
Expand Down Expand Up @@ -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);

Expand All @@ -201,7 +201,7 @@ public function storeFileFromHttpFile(
return $this;
}

function storeFileFromUrl(
public function storeFileFromUrl(
string $url,
string $collection_name = null,
string $basePath = null,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
$media->storeFile(
file: $this->dummy_pdf_url,
disk: 'media',
name: "foo"
name: 'foo'
);

expect($media->name)->toBe('foo');
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}

Expand All @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/FileDownloaderTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

use Finller\Media\FileDownloaders\FileDownloader;
use Finller\Media\Helpers\File;
use Illuminate\Http\UploadedFile;
use Spatie\TemporaryDirectory\TemporaryDirectory;

it('download a file from an url as a temporary file', function () {
Expand Down

0 comments on commit 30ace29

Please sign in to comment.