Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
plutuss committed Nov 5, 2024
2 parents 61cd2e4 + 6c98114 commit b446522
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class MediaAnalyzerController extends Controller

MediaAnalyzer::saveFileFromUrl(true) // Default false, if you want to save the file using the link
->setDisk('public') // You specify which disk
->setFilePath('images/') // You specify which path for the file
->setFileName('img') // You specify what name for the file
->setFilePath('music/') // You specify which path for the file
->setFileName('filename') // You specify what name for the file
->fromUrl($url);

```
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/MediaAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @method static MediaAnalyzerServiceInterface setDisk(string $disk)
* @method static MediaAnalyzerServiceInterface setPath(string $path)
* @method static MediaAnalyzerServiceInterface saveFileFromUrl(bool $saveFileFromUrl)
* @method static MediaAnalyzerResponseInterface fromUrl(string $url = true)
* @method static MediaAnalyzerResponseInterface fromUrl(string $url)
* @method static MediaAnalyzerResponseInterface setFileName(string $name)
* @method static MediaAnalyzerResponseInterface setFilePath(string $path)
*
Expand Down
30 changes: 18 additions & 12 deletions src/Services/MediaAnalyzerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class MediaAnalyzerService implements MediaAnalyzerServiceInterface

public function __construct(
protected GetID3 $getID3
)
{
) {
$this->managerService = app(MediaManagerServiceInterface::class);
}

Expand All @@ -47,11 +46,12 @@ public function __construct(
* @param $fp
* @return $this
*/
private function setData(string $file,
int|string $filesize = null,
?string $originalFileName = '',
$fp = null): static
{
private function setData(
string $file,
int|string $filesize = null,
?string $originalFileName = '',
$fp = null
): static {
$this->file = $file;
$this->filesize = $filesize;
$this->original_filename = $originalFileName;
Expand All @@ -69,7 +69,8 @@ private function getAnalyze(): Collection
$this->file,
$this->filesize,
$this->original_filename,
$this->fp);
$this->fp
);

$this->infoHasCommentsOrTags();

Expand Down Expand Up @@ -108,7 +109,8 @@ public function fromUrl(string $url): MediaAnalyzerResponseInterface

$response = $this->fromLocalFile(
$this->managerService->getPath(),
$this->getFilesystemsDisk());
$this->getFilesystemsDisk()
);

if (!$this->saveFileFromUrl) {
$this->managerService->delete();
Expand All @@ -125,8 +127,10 @@ public function fromUrl(string $url): MediaAnalyzerResponseInterface
*/
public function fromLocalFile(?string $path = null, ?string $disk = null): MediaAnalyzerResponseInterface
{
if ($path) $this->path = $path;
if ($disk) $this->disk = $disk;
if ($path)
$this->path = $path;
if ($disk)
$this->disk = $disk;

$storage = Storage::disk(
$this->getFilesystemsDisk()
Expand Down Expand Up @@ -193,7 +197,8 @@ private function infoHasCommentsOrTags(): void
if (!Arr::has($this->info, ['comments', 'tags'])) {
$this->info = Arr::has($this->info, 'id3v2.comments') ?
Arr::set($this->info, 'tags.id3v2', Arr::get($this->info, 'id3v2.comments')) : $this->info;
};
}
;
}

/**
Expand All @@ -216,6 +221,7 @@ private function infoHasId3V2orId3V1(): void
public function saveFileFromUrl(bool $saveFileFromUrl = true): static
{
$this->saveFileFromUrl = $saveFileFromUrl;

return $this;
}

Expand Down

0 comments on commit b446522

Please sign in to comment.