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 | /** |
||
82 | * XmlStream constructor. |
||
83 | * |
||
84 | * Xml Stream acts like stream wrapper, that uses $transport stream to communicate with server. |
||
85 | * |
||
86 | * @param XmlParser $parser XmlParser instance used for converting XML to objects |
||
87 | * @param DuplexStreamInterface $transport Stream used as the transport |
||
88 | */ |
||
89 | public function __construct(XmlParser $parser, DuplexStreamInterface $transport = null) |
||
96 | |||
97 | public function setParser(XmlParser $parser) |
||
121 | |||
122 | /** |
||
123 | * Writes data to stream |
||
124 | * |
||
125 | * @param string $data Data to write |
||
126 | * @return bool |
||
127 | */ |
||
128 | public function write($data) |
||
138 | |||
139 | /** |
||
140 | * Starts new stream with specified attributes |
||
141 | * |
||
142 | * @param array $attributes Stream attributes |
||
143 | */ |
||
144 | public function start(array $attributes = []) |
||
154 | |||
155 | /** |
||
156 | * Gently closes stream |
||
157 | */ |
||
158 | public function close() |
||
167 | |||
168 | /** |
||
169 | * Checks if stream is opened |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function isOpened() |
||
177 | |||
178 | public function __get($name) |
||
182 | |||
183 | public function __set($name, $value) |
||
187 | |||
188 | public function __isset($name) |
||
192 | |||
193 | private function handleError(Error $element) |
||
201 | } |
||
202 |