$data */ public static function record(string $type, array $data = []): void { if (self::$path === null) { return; } file_put_contents(self::$path, json_encode(['type' => $type, ...$data], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)."\n", FILE_APPEND | LOCK_EX); } /** * @return list> */ public static function entries(): array { if (self::$path === null || ! is_file(self::$path)) { return []; } return array_values(array_map(fn (string $line): array => (array) json_decode($line, true), array_filter(explode("\n", (string) file_get_contents(self::$path))))); } public static function violations(): array { return array_values(array_filter(self::entries(), fn (array $entry): bool => ($entry['type'] ?? null) === 'violation')); } }