<?php

declare(strict_types=1);

namespace apexl\Io\modules\user\services;

use apexl\Config\ConfigurationInterface;
use apexl\Io\modules\user\exceptions\ClientCredentialsValidationException;

readonly final class ClientCredentialValidator
{
    public function __construct(private ConfigurationInterface $config) {}

    /**
     * @throws ClientCredentialsValidationException
     */
    public function assertValid(string $clientId, string $clientSecret): void
    {
        if (
            ($clientId !== $this->config->get('auth.client_id')) ||
            ($clientSecret !== $this->config->get('auth.client_secret'))
        ) {
            throw new ClientCredentialsValidationException();
        }
    }
}
