1 | <?php |
||
36 | class Frame implements FrameInterface |
||
37 | { |
||
38 | /** |
||
39 | * Holds the const for stomp frame colon. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | const COLON = ':'; |
||
44 | |||
45 | /** |
||
46 | * Holds the const for stomp frame escape. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | const ESCAPE = '\\'; |
||
51 | |||
52 | /** |
||
53 | * Holds the const for stomp frame newline. |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | const NEWLINE = "\n"; |
||
58 | |||
59 | /** |
||
60 | * Holds the const for stomp frame null. |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | const NULL = "\x00"; |
||
65 | |||
66 | /** |
||
67 | * Holds the message command. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $command; |
||
72 | |||
73 | /** |
||
74 | * Holds the message headers. |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | protected $headers; |
||
79 | |||
80 | /** |
||
81 | * Holds the message body. |
||
82 | * |
||
83 | * @var string |
||
84 | */ |
||
85 | protected $body; |
||
86 | |||
87 | /** |
||
88 | * Create new stomp protocol frame. |
||
89 | * |
||
90 | * @param string $command The message command. |
||
91 | * @param array $headers The message headers. |
||
92 | * @param string $body The message body. |
||
93 | */ |
||
94 | public function __construct($command = null, array $headers = array(), $body = "") |
||
100 | |||
101 | /** |
||
102 | * Returns the message headers. |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | public function getHeaders() |
||
110 | |||
111 | /** |
||
112 | * Set the headers. |
||
113 | * |
||
114 | * @param array $headers The headers to set. |
||
115 | * |
||
116 | * @return void |
||
117 | * |
||
118 | * @link http://stomp.github.io/stomp-specification-1.1.html#Repeated_Header_Entries |
||
119 | */ |
||
120 | public function setHeaders(array $headers) |
||
132 | |||
133 | /** |
||
134 | * Returns the value for the given header key. |
||
135 | * |
||
136 | * @param string $key The header to find the value |
||
137 | * |
||
138 | * @return string|null |
||
139 | */ |
||
140 | public function getHeaderValueByKey($key) |
||
144 | |||
145 | /** |
||
146 | * Set the value for the given header key. |
||
147 | * |
||
148 | * @param string $key The header to find the value |
||
149 | * @param string $value The value to set |
||
150 | * |
||
151 | * @return void |
||
152 | */ |
||
153 | public function setHeaderValueByKey($key, $value) |
||
162 | |||
163 | /** |
||
164 | * Returns the message body. |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | public function getBody() |
||
172 | |||
173 | /** |
||
174 | * Set the body for the frame. |
||
175 | * |
||
176 | * @param string $body The body to set. |
||
177 | * |
||
178 | * @return void |
||
179 | */ |
||
180 | public function setBody($body) |
||
189 | |||
190 | /** |
||
191 | * Returns the frame object as string. |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function __toString() |
||
205 | |||
206 | /** |
||
207 | * Convert the frame headers to string. |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | protected function headersToString() |
||
224 | |||
225 | /** |
||
226 | * Encode the header string as stomp header string. |
||
227 | * |
||
228 | * @param string $value The value to convert |
||
229 | * |
||
230 | * @return string |
||
231 | */ |
||
232 | protected function encodeHeaderString($value) |
||
246 | |||
247 | /** |
||
248 | * Returns is for the current frame encode header required. |
||
249 | * |
||
250 | * @return bool |
||
251 | */ |
||
252 | protected function getHeaderEncodingRequired() |
||
263 | |||
264 | /** |
||
265 | * Returns the message command. |
||
266 | * |
||
267 | * @return string |
||
268 | */ |
||
269 | public function getCommand() |
||
273 | |||
274 | /** |
||
275 | * Set the command for the frame. |
||
276 | * |
||
277 | * @param string $command The Command to set. |
||
278 | * |
||
279 | * @return void |
||
280 | */ |
||
281 | public function setCommand($command) |
||
285 | } |
||
286 |