1 | <?php |
||
28 | class SaxParser |
||
29 | { |
||
30 | /** |
||
31 | * @var StreamAdapterInterface[] |
||
32 | */ |
||
33 | private $streamAdapters; |
||
34 | |||
35 | /** |
||
36 | * SaxParser constructor. |
||
37 | * |
||
38 | * @param StreamAdapterInterface[] $streamAdapters Stream adapters to register to parser. |
||
39 | */ |
||
40 | 3 | public function __construct(array $streamAdapters = array()) |
|
48 | |||
49 | /** |
||
50 | * Register stream adapter to parser. |
||
51 | * |
||
52 | * @param StreamAdapterInterface $streamAdapter Stream adapter to register. |
||
53 | * @return SaxParser $this Fluent interface. |
||
54 | */ |
||
55 | 3 | public function addStreamAdapter(StreamAdapterInterface $streamAdapter) |
|
60 | |||
61 | /** |
||
62 | * Parse XML document using provided SAX handler. |
||
63 | * |
||
64 | * @param SaxHandlerInterface $saxHandler Handler to user for parsing document. |
||
65 | * @param mixed $xmlDocument XML document source. |
||
66 | * |
||
67 | * @return mixed Parsing result. |
||
68 | */ |
||
69 | 3 | public function parse(SaxHandlerInterface $saxHandler, $xmlDocument) |
|
74 | |||
75 | /** |
||
76 | * Default SAX parser factory. |
||
77 | * |
||
78 | * @param string $streamClass FQCN to use when converting to XML document source to stream. |
||
79 | * @return SaxParser New SAX parser instance. |
||
80 | */ |
||
81 | 1 | public static function factory($streamClass = 'GuzzleHttp\\Psr7\\Stream') |
|
90 | |||
91 | /** |
||
92 | * Convert XML document to stream source. |
||
93 | * |
||
94 | * @param mixed $xmlDocument XML document source. |
||
95 | * @return StreamInterface Converted XML document to stream. |
||
96 | * |
||
97 | * @throws \RuntimeException |
||
98 | */ |
||
99 | 3 | private function getDocumentStream($xmlDocument) |
|
113 | } |
||
114 |