photo/app/Media/Factory.php

31 lines
540 B
PHP
Raw Normal View History

2024-09-16 12:10:19 +00:00
<?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,
2024-09-24 11:55:40 +00:00
'video/x-msvideo' => MSVideo::class,
2024-09-16 12:10:19 +00:00
];
/**
* 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);
}
}