/** * Given the TSPropertyArray binary data, extract out all of the TSProperty values. * * @param string $tsPropArray * @return array */ protected function decode($tsPropArray) { $tsPropArray = bin2hex($tsPropArray); // The signature is a 2-byte unicode character at the front $this->signature = MBString::chr(hexdec(substr($tsPropArray, 0, 2))); // The property count is a 2-byte unsigned integer indicating the number of elements for the tsPropertyArray // It starts at position 2. The actual variable data begins at position 4. $length = $this->addTSPropData(substr($tsPropArray, 4), hexdec(substr($tsPropArray, 2, 2))); // Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray // This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there if (strlen($tsPropArray) > 4 + $length) { $this->postBinary = hex2bin(substr($tsPropArray, 4 + $length)); } }