1 | <?php |
||
18 | class Message |
||
19 | { |
||
20 | /** |
||
21 | * It allows ~50MiB buffering as the default of Frame content is 0.5MB |
||
22 | */ |
||
23 | const MAX_MESSAGES_BUFFERING = 100; |
||
24 | |||
25 | /** |
||
26 | * @var array|Frame[] |
||
27 | */ |
||
28 | private $frames; |
||
29 | |||
30 | /** |
||
31 | * @var bool |
||
32 | */ |
||
33 | private $isComplete; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $buffer; |
||
39 | |||
40 | /** |
||
41 | * @see Message::setConfig() for full default configuration. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | private $config; |
||
46 | |||
47 | 51 | public function __construct(array $config = []) |
|
54 | |||
55 | /** |
||
56 | * Add some data to the buffer. |
||
57 | * |
||
58 | * @param $data |
||
59 | */ |
||
60 | 15 | public function addBuffer($data) |
|
64 | |||
65 | /** |
||
66 | * Clear the buffer. |
||
67 | */ |
||
68 | 1 | public function clearBuffer() |
|
72 | |||
73 | /** |
||
74 | * Get data inside the buffer. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | 15 | public function getBuffer() |
|
82 | |||
83 | /** |
||
84 | * Remove data from the start of the buffer. |
||
85 | * |
||
86 | * @param Frame $frame |
||
87 | * @return string |
||
88 | */ |
||
89 | 10 | public function removeFromBuffer(Frame $frame) : string |
|
95 | |||
96 | /** |
||
97 | * @param Frame $frame |
||
98 | * @return Message |
||
99 | * @throws \InvalidArgumentException |
||
100 | * @throws LimitationException |
||
101 | * @throws WrongEncodingException |
||
102 | */ |
||
103 | 45 | public function addFrame(Frame $frame) : Message |
|
126 | |||
127 | /** |
||
128 | * @return Frame |
||
129 | * @throws MissingDataException |
||
130 | */ |
||
131 | 41 | public function getFirstFrame() : Frame |
|
139 | |||
140 | /** |
||
141 | * This could in the future be deprecated in favor of a stream object. |
||
142 | * |
||
143 | * @return string |
||
144 | * @throws MissingDataException |
||
145 | */ |
||
146 | 26 | public function getContent() : string |
|
160 | |||
161 | /** |
||
162 | * @return int |
||
163 | */ |
||
164 | 19 | public function getOpcode() |
|
168 | |||
169 | /** |
||
170 | * @return bool |
||
171 | */ |
||
172 | 45 | public function isComplete() |
|
176 | |||
177 | /** |
||
178 | * @return bool |
||
179 | */ |
||
180 | public function isOperation() |
||
184 | |||
185 | /** |
||
186 | * @return Frame[] |
||
187 | */ |
||
188 | 4 | public function getFrames() |
|
192 | |||
193 | /** |
||
194 | * @return bool |
||
195 | */ |
||
196 | 11 | public function hasFrames() |
|
200 | |||
201 | /** |
||
202 | * @return int |
||
203 | */ |
||
204 | public function countFrames() : int |
||
208 | |||
209 | /** |
||
210 | * @param array $config |
||
211 | * @return Message |
||
212 | */ |
||
213 | 51 | public function setConfig(array $config = []) |
|
221 | } |
||
222 |