1 | <?php |
||
12 | class CustomXmlDecoder implements DecoderInterface |
||
13 | { |
||
14 | /** @var array Decoded data */ |
||
15 | protected $arrayData = []; |
||
16 | |||
17 | /** |
||
18 | * This is the method, which does the decoding work. |
||
19 | * |
||
20 | * @param $data |
||
21 | * @return array |
||
22 | */ |
||
23 | public function decode($data) |
||
24 | { |
||
25 | $xml = simplexml_load_string($data, "SimpleXMLElement", LIBXML_NOCDATA); |
||
26 | $json = json_encode($xml); |
||
27 | $this->arrayData = json_decode($json, true); |
||
28 | return $this->arrayData; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * The data returned is the actual file extensions supported for the files to decode. |
||
33 | * For instance, if you want to decode Yaml files with the extensions ".yml" and ".yaml", |
||
34 | * then you want to set the return array to ['yaml', 'yml']. |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | public function getMimeType() |
||
42 | } |
||
43 |