<?php

declare(strict_types=1);

namespace App\Core;

final class Audit
{
    public static function log(string $action, string $entity, ?int $entityId = null): void
    {
        Auth::start();
        Database::insert('audit_logs', [
            'user_id'    => $_SESSION['user_id'] ?? null,
            'action'     => $action,
            'entity'     => $entity,
            'entity_id'  => $entityId,
            'ip'         => $_SERVER['REMOTE_ADDR'] ?? '',
            'created_at' => date('Y-m-d H:i:s'),
        ]);
    }
}
