| @@ 29-38 (lines=10) @@ | ||
| 26 | * |
|
| 27 | * @todo UTF-8 validation, maybe. |
|
| 28 | */ |
|
| 29 | private function parseShortString() |
|
| 30 | { |
|
| 31 | $length = \ord($this->buffer); |
|
| 32 | ||
| 33 | try { |
|
| 34 | return \substr($this->buffer, 1, $length); |
|
| 35 | } finally { |
|
| 36 | $this->buffer = \substr($this->buffer, $length + 1); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Parse an AMQP "long string" from the head of the buffer. |
|
| @@ 46-55 (lines=10) @@ | ||
| 43 | * @todo UTF-8 validation, maybe. |
|
| 44 | * @return string |
|
| 45 | */ |
|
| 46 | private function parseLongString() |
|
| 47 | { |
|
| 48 | list(, $length) = \unpack('N', $this->buffer); |
|
| 49 | ||
| 50 | try { |
|
| 51 | return \substr($this->buffer, 4, $length); |
|
| 52 | } finally { |
|
| 53 | $this->buffer = \substr($this->buffer, $length + 4); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Parse a 8-bit signed integer from the head of the buffer. |
|
| @@ 172-181 (lines=10) @@ | ||
| 169 | * Parse an AMQP byte-array value. |
|
| 170 | * @return array |
|
| 171 | */ |
|
| 172 | private function parseByteArray() |
|
| 173 | { |
|
| 174 | list(, $length) = unpack('N', $this->buffer); |
|
| 175 | ||
| 176 | try { |
|
| 177 | return substr($this->buffer, 4, $length); |
|
| 178 | } finally { |
|
| 179 | $this->buffer = substr($this->buffer, $length + 4); |
|
| 180 | } |
|
| 181 | } |
|
| 182 | } |
|
| 183 | ||