<?php

declare(strict_types=1);

namespace App\Domain\Media;

final readonly class ImageVariantConfig
{
    public static function getAllVariants(): array
    {
        $variants = [];

        foreach (ImageVariantType::cases() as $type) {
            foreach ($type->getSizes() as $size) {
                foreach (ImageFormat::cases() as $format) {
                    $variants[] = [
                        'type' => $type,
                        'size' => $size,
                        'format' => $format,
                        'width' => $size->getWidth($type),
                    ];
                }
            }
        }

        return $variants;
    }

    public static function getVariantsForType(ImageVariantType $type): array
    {
        $variants = [];

        foreach ($type->getSizes() as $size) {
            foreach (ImageFormat::cases() as $format) {
                $variants[] = [
                    'type' => $type,
                    'size' => $size,
                    'format' => $format,
                    'width' => $size->getWidth($type),
                ];
            }
        }

        return $variants;
    }
}
