Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
SmtpConfigurationNotFoundException
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 forMissingConfiguration
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Mail\Domain\Exception;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use RuntimeException;
12
13/**
14 * Exception thrown when no active SMTP server configuration is available for mail delivery.
15 *
16 * @package App\Modules\Mail\Domain\Exception
17 */
18final class SmtpConfigurationNotFoundException extends RuntimeException
19{
20    /**
21     * Creates a new instance for missing active SMTP configuration.
22     *
23     * @param int|null $smtpId Optional SMTP server ID.
24     * @return self New exception instance.
25     */
26    public static function forMissingConfiguration(?int $smtpId = null): self
27    {
28        if ($smtpId !== null && $smtpId > 0) {
29            return new self(sprintf('SMTP server configuration with ID %d not found or inactive.', $smtpId));
30        }
31
32        return new self('No active default SMTP server configuration available.');
33    }
34}