(mixed $filters, array $reportIds)
| 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); |
no test coverage detected