1 | <?php |
||
18 | class Message |
||
19 | { |
||
20 | const MAX_MESSAGES_BUFFERING = 1000; |
||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $frames; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $isComplete; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $buffer; |
||
35 | |||
36 | 43 | public function __construct() |
|
42 | |||
43 | /** |
||
44 | * Add some data to the buffer. |
||
45 | * |
||
46 | * @param $data |
||
47 | */ |
||
48 | 15 | public function addBuffer($data) |
|
52 | |||
53 | /** |
||
54 | * Clear the buffer. |
||
55 | */ |
||
56 | 1 | public function clearBuffer() |
|
60 | |||
61 | /** |
||
62 | * Get data inside the buffer. |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | 15 | public function getBuffer() |
|
70 | |||
71 | /** |
||
72 | * Remove data from the start of the buffer. |
||
73 | * |
||
74 | * @param Frame $frame |
||
75 | * @return string |
||
76 | */ |
||
77 | 10 | public function removeFromBuffer(Frame $frame) : string |
|
83 | |||
84 | /** |
||
85 | * @param Frame $frame |
||
86 | * @return Message |
||
87 | * @throws \InvalidArgumentException |
||
88 | * @throws LimitationException |
||
89 | * @throws WrongEncodingException |
||
90 | */ |
||
91 | 38 | public function addFrame(Frame $frame) : Message |
|
114 | |||
115 | /** |
||
116 | * @return Frame |
||
117 | * @throws MissingDataException |
||
118 | */ |
||
119 | 35 | public function getFirstFrame() : Frame |
|
127 | |||
128 | /** |
||
129 | * This could in the future be deprecated in favor of a stream object. |
||
130 | * |
||
131 | * @return string |
||
132 | * @throws MissingDataException |
||
133 | */ |
||
134 | 16 | public function getContent() : string |
|
148 | |||
149 | /** |
||
150 | * @return int |
||
151 | */ |
||
152 | 19 | public function getOpcode() |
|
156 | |||
157 | /** |
||
158 | * @return bool |
||
159 | */ |
||
160 | 38 | public function isComplete() |
|
164 | |||
165 | /** |
||
166 | * @return bool |
||
167 | */ |
||
168 | public function isOperation() |
||
172 | |||
173 | /** |
||
174 | * @return Frame[] |
||
175 | */ |
||
176 | 4 | public function getFrames() |
|
180 | |||
181 | /** |
||
182 | * @return bool |
||
183 | */ |
||
184 | 11 | public function hasFrames() |
|
188 | |||
189 | /** |
||
190 | * @return int |
||
191 | */ |
||
192 | public function countFrames() : int |
||
196 | } |
||
197 |