<?php

declare(strict_types=1);

namespace App\Service\Theme;

final class ThemeResolver
{
    /**
     * @return array<int, array{code: string, label: string}>
     */
    public function availableThemes(): array
    {
        return [
            ['code' => 'qamar', 'label' => 'Qamar'],
            ['code' => 'daroul_ilm', 'label' => 'Daroul-Ilm'],
            ['code' => 'sahaba', 'label' => 'Sahaba'],
        ];
    }

    public function resolvePublicTheme(mixed $requestedTheme): string
    {
        $theme = is_string($requestedTheme) ? trim($requestedTheme) : '';

        foreach ($this->availableThemes() as $availableTheme) {
            if ($availableTheme['code'] === $theme) {
                return $theme;
            }
        }

        return 'qamar';
    }
}
