Total Complexity | 8 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
21 | final class FormatMatcher |
||
22 | { |
||
23 | private $formats; |
||
24 | |||
25 | public function __construct(array $formats) |
||
26 | { |
||
27 | $normalizedFormats = []; |
||
28 | foreach ($formats as $format => $mimeTypes) { |
||
29 | $normalizedFormats[$format] = (array) $mimeTypes; |
||
30 | } |
||
31 | $this->formats = $normalizedFormats; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Gets the format associated with the mime type. |
||
36 | * |
||
37 | * Adapted from {@see \Symfony\Component\HttpFoundation\Request::getFormat}. |
||
38 | */ |
||
39 | public function getFormat(string $mimeType): ?string |
||
57 | } |
||
58 | } |
||
59 |