'.jpg', self::BMP => '.bmp', self::PNG => '.png', self::TIFF => '.tif', }; } public static function FromFile(?string $path): ?ImageMimeType{ if($path === null || $path == ''){ return null; } try{ $mimeType = mime_content_type($path); } catch(\Safe\Exceptions\FileinfoException){ return null; } $mimeType = match($mimeType){ 'image/x-ms-bmp', 'image/x-bmp' => 'image/bmp', default => $mimeType, }; if(!$mimeType){ return null; } return ImageMimeType::tryFrom($mimeType); } /** * @return array */ public static function Values(): array{ return array_map(function(ImageMimeType $case){ return $case->value; }, ImageMimeType::cases()); } }