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