MCPcopy Create free account
hub / github.com/Rello/analytics / resolve

Method resolve

lib/Storage/DatasetStorageResolver.php:28–42  ·  view source on GitHub ↗

@return array{dataset:array ,mode:string,mapper:StorageMapper|FlexibleStorageMapper,tables:array{columns:?string,records:string,values:?string}} */

(int $datasetId, bool $ownerOnly = false)

Source from the content-addressed store, hash-verified

26
27 /** @return array{dataset:array<string,mixed>,mode:string,mapper:StorageMapper|FlexibleStorageMapper,tables:array{columns:?string,records:string,values:?string}} */
28 public function resolve(int $datasetId, bool $ownerOnly = false): array {
29 $dataset = $ownerOnly ? $this->datasetMapper->readOwn($datasetId) : $this->datasetMapper->read($datasetId);
30 if (!is_array($dataset) || $dataset === []) {
31 throw new FlexibleStorageException('dataset_not_found', 'The dataset does not exist or is not accessible.', ['datasetId' => $datasetId], 404);
32 }
33
34 $mode = (string)($dataset['storage_mode'] ?? self::LEGACY);
35 [$mapper, $tables] = match ($mode) {
36 self::LEGACY => [$this->legacyMapper, ['columns' => null, 'records' => 'analytics_facts', 'values' => null]],
37 self::FLEXIBLE_SHARED => [$this->flexibleMapper, ['columns' => 'analytics_flex_columns', 'records' => 'analytics_flex_records', 'values' => 'analytics_flex_values']],
38 default => throw new FlexibleStorageException('unsupported_storage_mode', 'The dataset uses an unsupported storage mode.', ['datasetId' => $datasetId, 'storageMode' => $mode], 409),
39 };
40
41 return ['dataset' => $dataset, 'mode' => $mode, 'mapper' => $mapper, 'tables' => $tables];
42 }
43}

Callers

nothing calls this directly

Calls 2

readOwnMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected