$body * @return list elk punt heeft "at" en het veld $valueKey */ public static function map(array $body, \DateTimeZone $tz, string $valueKey): array { $points = []; foreach ($body as $timestamp => $values) { if (!is_numeric($timestamp) || !is_array($values) || !isset($values[0]) || !is_numeric($values[0])) { continue; } $points[(int) $timestamp] = (float) $values[0]; } ksort($points); $out = []; foreach ($points as $ts => $value) { $out[] = [ 'at' => (new \DateTimeImmutable('@' . $ts))->setTimezone($tz)->format(\DATE_ATOM), $valueKey => $value, ]; } return $out; } }