1 | <?php |
||
8 | final class DecoderManager |
||
9 | { |
||
|
|||
10 | /** |
||
11 | * @var ParserInterface[] |
||
12 | */ |
||
13 | private $decoders = []; |
||
14 | |||
15 | /** |
||
16 | * @var bool |
||
17 | */ |
||
18 | private $ignoreUnknownExtension = []; |
||
19 | |||
20 | /** |
||
21 | * @param DecoderInterface[] $decoders |
||
22 | */ |
||
23 | 104 | public function __construct(array $decoders = [], $ignoreUnknownExtension = true) |
|
35 | |||
36 | /** |
||
37 | * Register a DecoderInterface for the given extension. |
||
38 | * |
||
39 | * @param DecoderInterface $decoder |
||
40 | */ |
||
41 | 104 | public function registerDecoder($extension, DecoderInterface $decoder) |
|
45 | |||
46 | /** |
||
47 | * Get all registered decoders, keyed by the extensions they are registered to decode schemas for. |
||
48 | * |
||
49 | * @return DecoderInterface[] |
||
50 | */ |
||
51 | 2 | public function getDecoders() |
|
55 | |||
56 | /** |
||
57 | * Set to true to use default decoder for unknown file extensions |
||
58 | * |
||
59 | * @param bool |
||
60 | */ |
||
61 | public function setIgnoreUnknownExtension($ignoreUnknownExtension) |
||
65 | |||
66 | /** |
||
67 | * Get the decoder for the given extension. |
||
68 | * |
||
69 | * @param string $extension |
||
70 | * |
||
71 | * @return DecoderInterface |
||
72 | * @throws \InvalidArgumentException |
||
73 | */ |
||
74 | 58 | public function getDecoder($extension) |
|
84 | |||
85 | /** |
||
86 | * @param string $extension |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | 60 | public function hasDecoder($extension) |
|
94 | |||
95 | /** |
||
96 | * Register the default decoder. |
||
97 | */ |
||
98 | 102 | private function registerDefaultDecoder() |
|
104 | } |
||
105 |