public function readByType(array $type, $isCollectionElement = false)
{
if ($this->data === null) {
return null;
}
switch ($type['type']) {
case DataTypeEnum::ASCII:
case DataTypeEnum::VARCHAR:
case DataTypeEnum::TEXT:
return $isCollectionElement ? $this->readString() : $this->data;
case DataTypeEnum::BIGINT:
case DataTypeEnum::COUNTER:
return $this->readBigInt($isCollectionElement);
case DataTypeEnum::VARINT:
return $this->readVarint($isCollectionElement);
case DataTypeEnum::CUSTOM:
case DataTypeEnum::BLOB:
return $this->readBytes($isCollectionElement);
case DataTypeEnum::BOOLEAN:
return $this->readBoolean();
case DataTypeEnum::DECIMAL:
return $this->readDecimal($isCollectionElement);
case DataTypeEnum::DOUBLE:
return $this->readDouble($isCollectionElement);
case DataTypeEnum::FLOAT:
return $this->readFloat($isCollectionElement);
case DataTypeEnum::INT:
return $this->readInt($isCollectionElement);
case DataTypeEnum::TIMESTAMP:
return $this->readTimestamp();
case DataTypeEnum::UUID:
return $this->readUuid($isCollectionElement);
case DataTypeEnum::TIMEUUID:
return $this->readUuid($isCollectionElement);
case DataTypeEnum::INET:
return $this->readInet($isCollectionElement);
case DataTypeEnum::COLLECTION_LIST:
case DataTypeEnum::COLLECTION_SET:
return $this->readList($type['value']);
case DataTypeEnum::COLLECTION_MAP:
return $this->readMap($type['key'], $type['value']);
}
trigger_error('Unknown type ' . var_export($type, true));
return null;
}