/** * @param int $numBytes * @param int $intSize * @return JsonBinaryDecoderValue * @throws BinaryDataReaderException * @throws \LengthException */ private function parseValueType($numBytes, $intSize) { $type = $this->binaryDataReader->readInt8(); if (self::LITERAL === $type) { return new JsonBinaryDecoderValue(true, $this->readLiteral(), $type); } else { if (self::INT16 === $type) { return new JsonBinaryDecoderValue(true, $this->binaryDataReader->readInt16(), $type); } else { if (self::UINT16 === $type) { return new JsonBinaryDecoderValue(true, $this->binaryDataReader->readUInt16(), $type); } else { if (BinaryDataReader::UNSIGNED_INT32_LENGTH === $intSize) { if (self::INT32 === $type) { return new JsonBinaryDecoderValue(true, $this->binaryDataReader->readInt32(), $type); } else { if (self::UINT32 === $type) { return new JsonBinaryDecoderValue(true, $this->binaryDataReader->readUInt32(), $type); } } } else { $offset = $this->binaryDataReader->readUIntBySize($intSize); if ($offset > $numBytes) { throw new \LengthException('The offset for the value in the JSON binary document is ' . $offset . ', which is larger than the binary form of the JSON document (' . $numBytes . ' bytes)'); } return new JsonBinaryDecoderValue(false, null, $type); } } } } }