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

Method mapFilters

lib/Service/BundleDefinition.php:95–107  ·  view source on GitHub ↗
(mixed $filters, array $reportIds)

Source from the content-addressed store, hash-verified

93 }
94
95 public static function mapFilters(mixed $filters, array $reportIds): array {
96 self::check(is_array($filters) && array_is_list($filters), 'Invalid Panorama filters');
97 foreach ($filters as &$filter) {
98 self::check(is_array($filter) && is_array($filter['mappings'] ?? null), 'Invalid filter mappings');
99 foreach ($filter['mappings'] as &$mapping) {
100 self::check(is_array($mapping) && is_string($mapping['reportId'] ?? null) && isset($reportIds[$mapping['reportId']]), 'Unknown filter report');
101 $mapping['reportId'] = $reportIds[$mapping['reportId']];
102 }
103 unset($mapping);
104 }
105 unset($filter);
106 return $filters;
107 }
108
109 private static function check(bool $condition, string $message): void {
110 if (!$condition) throw new InvalidArgumentException($message);

Callers 2

validateMethod · 0.95
importBundleMethod · 0.80

Calls 1

checkMethod · 0.95

Tested by

no test coverage detected