1 | <?php |
||
46 | class XmlStream extends StreamDecorator // implements BetterEmitterInterface // Some php cancer |
||
47 | { |
||
48 | use BetterEmitter, Logging; |
||
49 | |||
50 | /** XML namespace of stream */ |
||
51 | const NAMESPACE_URI = 'http://etherx.jabber.org/streams'; |
||
52 | |||
53 | /** |
||
54 | * XmlParser reference |
||
55 | * |
||
56 | * @var XmlParser |
||
57 | */ |
||
58 | protected $_parser; |
||
59 | |||
60 | /** |
||
61 | * @var bool |
||
62 | * |
||
63 | * @see XmlStream::isOpened |
||
64 | */ |
||
65 | private $_isOpened = false; |
||
66 | |||
67 | /** |
||
68 | * Inbound Stream root element |
||
69 | * |
||
70 | * @var XmlElement |
||
71 | */ |
||
72 | private $_inbound; |
||
73 | |||
74 | /** |
||
75 | * Outbound Stream root element |
||
76 | * |
||
77 | * @var XmlElement |
||
78 | */ |
||
79 | private $_outbound; |
||
80 | |||
81 | private $_attributes = []; |
||
82 | |||
83 | /** |
||
84 | * XmlStream constructor. |
||
85 | * |
||
86 | * Xml Stream acts like stream wrapper, that uses $transport stream to communicate with server. |
||
87 | * |
||
88 | * @param XmlParser $parser XmlParser instance used for converting XML to objects |
||
89 | * @param DuplexStreamInterface $transport Stream used as the transport |
||
90 | */ |
||
91 | 9 | public function __construct(XmlParser $parser, DuplexStreamInterface $transport = null) |
|
101 | |||
102 | 8 | public function setParser(XmlParser $parser) |
|
126 | |||
127 | /** |
||
128 | * Writes data to stream |
||
129 | * |
||
130 | * @param string $data Data to write |
||
131 | * @return bool |
||
132 | */ |
||
133 | public function write($data) |
||
143 | |||
144 | /** |
||
145 | * Starts new stream with specified attributes |
||
146 | * |
||
147 | * @param array $attributes Stream attributes |
||
148 | */ |
||
149 | public function start(array $attributes = []) |
||
160 | |||
161 | public function restart() |
||
166 | |||
167 | /** |
||
168 | * Gently closes stream |
||
169 | */ |
||
170 | public function close() |
||
179 | |||
180 | /** |
||
181 | * Checks if stream is opened |
||
182 | * |
||
183 | * @return bool |
||
184 | */ |
||
185 | public function isOpened() |
||
189 | |||
190 | public function __get($name) |
||
194 | |||
195 | public function __set($name, $value) |
||
199 | |||
200 | public function __isset($name) |
||
204 | |||
205 | private function handleError(Error $element) |
||
213 | } |
||
214 |