<?php

declare(strict_types=1);

namespace App\Models;

use App\Core\Database;

/**
 * Profils de dérivés d'images (D-26). Lecture seule pour l'instant.
 */
final class ImageProfile
{
    /** @var list<array<string,mixed>>|null */
    private static ?array $cache = null;

    /** @return list<array<string,mixed>> */
    public static function all(): array
    {
        if (self::$cache !== null) {
            return self::$cache;
        }
        $pdo = Database::connection();
        $rows = $pdo->query('SELECT `key`, label, width, height, crop, orientation, webp FROM image_profiles ORDER BY id ASC')->fetchAll();
        self::$cache = is_array($rows) ? $rows : [];
        return self::$cache;
    }
}
