/** * Method to decode the response of the packet. * @return array An array with the decoded response. * @since 1.0.0 */ public function decodeResponse() { $words = array(); $offset = 0; $size = Encoding::decodeInt32(mb_substr($this->response, 4, 4)) - 12; $response = mb_substr($this->response, 12); //decode the whole response. while ($offset < $size) { $wordLen = Encoding::decodeInt32(mb_substr($response, $offset, 4)); $word = mb_substr($response, $offset + 4, $wordLen); array_push($words, $word); $offset += (int) $wordLen + 5; } //return the decoded response. return $words; }