31 lines
964 B
PHP
31 lines
964 B
PHP
<?php
|
|
|
|
namespace App\Services\Providers;
|
|
|
|
use App\Models\Tenant;
|
|
use RuntimeException;
|
|
|
|
final class ProviderConfigurationRequiredException extends RuntimeException
|
|
{
|
|
public function __construct(
|
|
public readonly int $tenantId,
|
|
public readonly string $provider,
|
|
public readonly string $reasonCode,
|
|
public readonly ?string $extensionReasonCode = null,
|
|
string $message = 'Provider configuration is required.',
|
|
) {
|
|
parent::__construct($message);
|
|
}
|
|
|
|
public static function forTenant(Tenant $tenant, string $provider, ProviderConnectionResolution $resolution): self
|
|
{
|
|
return new self(
|
|
tenantId: (int) $tenant->getKey(),
|
|
provider: $provider,
|
|
reasonCode: $resolution->effectiveReasonCode(),
|
|
extensionReasonCode: $resolution->extensionReasonCode,
|
|
message: $resolution->message ?? 'Provider configuration is required.',
|
|
);
|
|
}
|
|
}
|