1 | <?php |
||
17 | class Parser |
||
18 | { |
||
19 | const FORMAT_JSON = 'json'; |
||
20 | const FORMAT_XML = 'xml'; |
||
21 | |||
22 | /** |
||
23 | * @var ParserInterface[] |
||
24 | */ |
||
25 | private $parsers = []; |
||
26 | |||
27 | /** |
||
28 | * @param ParserInterface[] $parsers |
||
29 | */ |
||
30 | public function __construct(array $parsers = []) |
||
34 | |||
35 | /** |
||
36 | * @return bool |
||
37 | */ |
||
38 | public function hasParsers() |
||
42 | |||
43 | /** |
||
44 | * @return ParserInterface[] |
||
45 | */ |
||
46 | public function getParsers() |
||
50 | |||
51 | /** |
||
52 | * @param ParserInterface[] $parsers |
||
53 | */ |
||
54 | public function setParsers(array $parsers) |
||
59 | |||
60 | /** |
||
61 | * @param ParserInterface[] $parsers |
||
62 | */ |
||
63 | public function addParsers(array $parsers) |
||
69 | |||
70 | /** |
||
71 | * @param string $format |
||
72 | * |
||
73 | * @return bool |
||
74 | */ |
||
75 | public function hasParser($format) |
||
79 | |||
80 | /** |
||
81 | * @param string $format |
||
82 | * |
||
83 | * @return ParserInterface|null |
||
84 | */ |
||
85 | public function getParser($format) |
||
89 | |||
90 | /** |
||
91 | * @param string $format |
||
92 | * @param ParserInterface $parser |
||
93 | */ |
||
94 | public function setParser($format, ParserInterface $parser) |
||
98 | |||
99 | /** |
||
100 | * @param string $format |
||
101 | */ |
||
102 | public function removeParser($format) |
||
106 | |||
107 | /** |
||
108 | * @param string $data |
||
109 | * @param string $format |
||
110 | * @param array $options |
||
111 | * |
||
112 | * @return mixed[] |
||
113 | */ |
||
114 | public function parse($data, $format, array $options = []) |
||
124 | } |
||
125 |