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

Method resolveSort

lib/Service/FlexibleStorageService.php:729–750  ·  view source on GitHub ↗

@param list ,aggregation:string}> $projection */

(mixed $sort, FlexibleColumnResolver $resolver, array $projection)

Source from the content-addressed store, hash-verified

727
728 /** @param list<array{column:array<string,mixed>,aggregation:string}> $projection */
729 private function resolveSort(mixed $sort, FlexibleColumnResolver $resolver, array $projection): array {
730 if (!is_array($sort)) {
731 throw new FlexibleStorageException('invalid_sort', 'Sort options must be an array.');
732 }
733 $selected = array_column(array_column($projection, 'column'), 'ref');
734 $result = [];
735 foreach ($sort as $index => $item) {
736 if (!is_array($item)) {
737 throw new FlexibleStorageException('invalid_sort', 'Each sort option must be an object.', ['sort' => $index]);
738 }
739 $column = $resolver->resolve((string)($item['column'] ?? ''));
740 if (!in_array($column['ref'], $selected, true)) {
741 throw new FlexibleStorageException('invalid_sort', 'Sorting requires the column to be projected.', ['column' => $column['ref']]);
742 }
743 $direction = strtoupper((string)($item['direction'] ?? 'ASC'));
744 if (!in_array($direction, ['ASC', 'DESC'], true)) {
745 throw new FlexibleStorageException('invalid_sort', 'Sort direction must be ASC or DESC.', ['sort' => $index]);
746 }
747 $result[] = ['column' => $column, 'direction' => $direction];
748 }
749 return $result;
750 }
751
752 /** @param list<array{column:array<string,mixed>,aggregation:string}> $projection */
753 private function resolveTimeAggregation(mixed $option, FlexibleColumnResolver $resolver, array $projection, bool $aggregate): ?array {

Callers 1

queryMethod · 0.95

Calls 1

resolveMethod · 0.45

Tested by

no test coverage detected