file, json_encode($stats, JSON_UNESCAPED_UNICODE) . "\n"); } /** @return array|null null when no server wrote it lately */ public function read(int $maxAge = 10): ?array { $data = is_file($this->file) ? json_decode((string)file_get_contents($this->file), true) : null; if (!is_array($data) || (time() - (int)($data['at'] ?? 0)) > $maxAge) { return null; } return $data; } public function remove(): void { @unlink($this->file); } }