23 lines
531 B
PHP
23 lines
531 B
PHP
|
<?php
|
||
|
namespace Uiharu;
|
||
|
|
||
|
use Index\MediaType;
|
||
|
|
||
|
final class MediaTypeExts {
|
||
|
public static function toV1(MediaType $mediaType): array {
|
||
|
$parts = [
|
||
|
'string' => (string)$mediaType,
|
||
|
'type' => $mediaType->getCategory(),
|
||
|
'subtype' => $mediaType->getKind(),
|
||
|
];
|
||
|
|
||
|
if(!empty($suffix = $mediaType->getSuffix()))
|
||
|
$parts['suffix'] = $suffix;
|
||
|
|
||
|
if(!empty($params = $mediaType->getParams()))
|
||
|
$parts['params'] = $params;
|
||
|
|
||
|
return $parts;
|
||
|
}
|
||
|
}
|