1 | <?php |
||
26 | final class SaxParser |
||
27 | { |
||
28 | /** |
||
29 | * @var StreamAdapterInterface[] |
||
30 | */ |
||
31 | private $streamAdapters; |
||
32 | |||
33 | /** |
||
34 | * SaxParser constructor. |
||
35 | * |
||
36 | * @param StreamAdapterInterface[] $streamAdapters Stream adapters to register to parser. |
||
37 | */ |
||
38 | public function __construct(array $streamAdapters = array()) |
||
46 | |||
47 | /** |
||
48 | * Register stream adapter to parser. |
||
49 | * |
||
50 | * @param StreamAdapterInterface $streamAdapter Stream adapter to register. |
||
51 | */ |
||
52 | public function addStreamAdapter(StreamAdapterInterface $streamAdapter) |
||
56 | |||
57 | /** |
||
58 | * Parse XML document using provided SAX handler. |
||
59 | * |
||
60 | * @param SaxHandlerInterface $saxHandler Handler to user for parsing document. |
||
61 | * @param mixed $xmlDocument XML document source. |
||
62 | * @param callable|null $onResult Callable to execute when parsing is done. |
||
63 | */ |
||
64 | public function parse(SaxHandlerInterface $saxHandler, $xmlDocument, callable $onResult = null) |
||
69 | |||
70 | /** |
||
71 | * Convert XML document to stream source. |
||
72 | * |
||
73 | * @param mixed $xmlDocument XML document source. |
||
74 | * @return StreamInterface Converted XML document to stream. |
||
75 | */ |
||
76 | private function getDocumentStream($xmlDocument) |
||
94 | |||
95 | /** |
||
96 | * Default SAX parser factory. |
||
97 | * |
||
98 | * @param string $streamClass FQCN to use when converting to XML document source to stream. |
||
99 | * @return SaxParser New SAX parser instance. |
||
100 | */ |
||
101 | public static function factory($streamClass = 'GuzzleHttp\\Stream\\Stream') |
||
109 | } |
||
110 |