31 lines
540 B
PHP
31 lines
540 B
PHP
<?php
|
|
|
|
namespace App\Media;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
class Factory {
|
|
private const LOGKEY = 'MF-';
|
|
|
|
/**
|
|
* @var array event type to event class mapping
|
|
*/
|
|
public const map = [
|
|
'video/quicktime' => QuickTime::class,
|
|
'video/x-msvideo' => MSVideo::class,
|
|
];
|
|
|
|
/**
|
|
* Returns new event instance
|
|
*
|
|
* @param string $file
|
|
* @return Base
|
|
*/
|
|
public static function create(string $file): Base
|
|
{
|
|
$type = mime_content_type($file);
|
|
$class = Arr::get(self::map,$type,Unknown::class);
|
|
|
|
return new $class($file,$type);
|
|
}
|
|
} |