Skip to content

Commit

Permalink
Merge pull request #6 from plutuss/dev
Browse files Browse the repository at this point in the history
update:
  • Loading branch information
plutuss authored Oct 6, 2024
2 parents febc409 + a05eb87 commit d1ebc63
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 17 deletions.
13 changes: 13 additions & 0 deletions src/Response/MediaAnalyzerResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,17 @@ public function getFileFormat(): mixed;
* @return mixed
*/
public function getNestedValue(string $path, mixed $default = null): mixed;


/**
* @return mixed|string
*/
public function getPlaytimeSeconds(): mixed;


/**
* @param bool $withNumber
* @return mixed|null
*/
public function getFileSize(bool $withNumber = false): mixed;
}
19 changes: 2 additions & 17 deletions src/Traits/HasInfoFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@
trait HasInfoFile
{

/**
* @return string
*/
public function getDuration(): string
{
return date('H:i:s', $this->getNestedValue('playtime_seconds') ?? 0);
}
use HasNumberData;


/**
* @param string $key
Expand Down Expand Up @@ -94,15 +89,6 @@ public function getAlbum(): mixed
}


/**
* @return mixed|string
*/
public function getPlaytime(): mixed
{
return $this->getNestedValue('playtime_string') ?? '';
}


/**
* @return array|mixed
*/
Expand Down Expand Up @@ -156,5 +142,4 @@ public function getFileFormat(): mixed
return $this->getNestedValue('fileformat') ?? null;
}


}
48 changes: 48 additions & 0 deletions src/Traits/HasNumberData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Plutuss\Traits;

trait HasNumberData
{

/**
* @return string
*/
public function getDuration(): string
{
return date('H:i:s',
$this->getNestedValue('playtime_seconds') ?? 0);
}

/**
* @return mixed|string
*/
public function getPlaytime(): mixed
{
return $this->getNestedValue('playtime_string') ?? '';
}

/**
* @return mixed|string
*/
public function getPlaytimeSeconds(): mixed
{
return $this->getNestedValue('playtime_seconds') ?? '';
}


/**
* @param bool $withNumber
* @return mixed|string|null
*/
public function getFileSize(bool $withNumber = false): mixed
{
$filesize = $this->getNestedValue('filesize') ?? 0;

if ($withNumber) {
return \Illuminate\Support\Number::fileSize($filesize);
}

return $filesize;
}
}

0 comments on commit d1ebc63

Please sign in to comment.