<?php

declare(strict_types=1);

namespace App\Modules\Identity\Services;

use App\Modules\Identity\Support\OidcProviderConfig;

class OidcProviderService
{
    /**
     * @return array<int, OidcProviderConfig>
     */
    public function configuredProviders(): array
    {
        return [
            new OidcProviderConfig(
                providerKey: 'adfs-oidc-default',
                driver: 'oidc',
                clientId: 'tenant-client-id',
                redirectUri: '/auth/oidc/adfs-oidc-default/callback',
                scopes: ['openid', 'profile', 'email']
            ),
        ];
    }

    public function findProvider(string $providerKey): ?OidcProviderConfig
    {
        foreach ($this->configuredProviders() as $provider) {
            if ($provider->providerKey === $providerKey) {
                return $provider;
            }
        }

        return null;
    }
}
