<?php
/**
* @generated enum generated using bin/generate.php, please DO NOT EDIT!
*
* @codeCoverageIgnore
*/
declare(strict_types=1);
namespace %namespace%;
use InvalidArgumentException;
%interface_usage%
enum %classname%: string implements MimeTypeInterface
{
%cases%
#[\Override]
public function getExtension(): string
{
return match($this) {
%type2ext%
};
}
#[\Override]
public function getValue(): string
{
return $this->value;
}
public static function fromExtension(string $extension): MimeType
{
$type = self::tryFromExtension($extension);
if ($type === null) {
throw new InvalidArgumentException('Unknown extension: ' . $extension);
}
return $type;
}
public static function tryFromExtension(string $extension): ?MimeType
{
return match($extension) {
%ext2type%
default => null,
};
}
}
|