1 | <?php |
||
8 | final class DecoderManager |
||
9 | { |
||
10 | |||
11 | |||
12 | /** |
||
13 | * @var ParserInterface[] |
||
14 | */ |
||
15 | private $decoders = []; |
||
16 | |||
17 | /** |
||
18 | * @var bool |
||
19 | */ |
||
20 | private $ignoreUnknownExtension = []; |
||
21 | |||
22 | /** |
||
23 | * @param DecoderInterface[] $decoders |
||
24 | */ |
||
25 | public function __construct(array $decoders = [], $ignoreUnknownExtension = true) |
||
37 | |||
38 | /** |
||
39 | * Register a DecoderInterface for the given extension. |
||
40 | * |
||
41 | * @param DecoderInterface $decoder |
||
42 | */ |
||
43 | public function registerDecoder($extension, DecoderInterface $decoder) |
||
47 | |||
48 | /** |
||
49 | * Get all registered decoders, keyed by the extensions they are registered to decode schemas for. |
||
50 | * |
||
51 | * @return DecoderInterface[] |
||
52 | */ |
||
53 | public function getDecoders() |
||
57 | |||
58 | /** |
||
59 | * Set to true to use default decoder for unknown file extensions |
||
60 | * |
||
61 | * @param bool |
||
62 | */ |
||
63 | public function setIgnoreUnknownExtension($ignoreUnknownExtension) |
||
67 | |||
68 | /** |
||
69 | * Get the decoder for the given extension. |
||
70 | * |
||
71 | * @param string $extension |
||
72 | * |
||
73 | * @return DecoderInterface |
||
74 | * @throws \InvalidArgumentException |
||
75 | */ |
||
76 | public function getDecoder($extension) |
||
86 | |||
87 | /** |
||
88 | * @param string $extension |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function hasDecoder($extension) |
||
96 | |||
97 | /** |
||
98 | * Register the default decoder. |
||
99 | */ |
||
100 | private function registerDefaultDecoder() |
||
106 | } |
||
107 |