| 1 |
<?php |
| 2 |
/** |
| 3 |
* Outcome of re-sending a confirmation mail. |
| 4 |
* |
| 5 |
* @package Forge12\DoubleOptIn\Service |
| 6 |
* @since 5.8.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare( strict_types=1 ); |
| 10 |
|
| 11 |
namespace Forge12\DoubleOptIn\Service; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Either sent, or the reason it was not. The reasons are stable strings so |
| 19 |
* callers can phrase them for their own audience: the admin learns that a |
| 20 |
* record is already confirmed, a visitor must never learn anything. |
| 21 |
* |
| 22 |
* @api |
| 23 |
*/ |
| 24 |
final class ResendResult { |
| 25 |
|
| 26 |
public const SENT = 'sent'; |
| 27 |
public const NOT_FOUND = 'not_found'; |
| 28 |
public const CONFIRMED = 'confirmed'; |
| 29 |
public const OPTED_OUT = 'opted_out'; |
| 30 |
public const NO_BODY = 'no_body'; |
| 31 |
public const NO_RECIPIENT = 'no_recipient'; |
| 32 |
public const SEND_FAILED = 'send_failed'; |
| 33 |
|
| 34 |
/** @var string */ |
| 35 |
private $reason; |
| 36 |
|
| 37 |
private function __construct( string $reason ) { |
| 38 |
$this->reason = $reason; |
| 39 |
} |
| 40 |
|
| 41 |
public static function sent(): self { |
| 42 |
return new self( self::SENT ); |
| 43 |
} |
| 44 |
|
| 45 |
public static function refused( string $reason ): self { |
| 46 |
return new self( $reason ); |
| 47 |
} |
| 48 |
|
| 49 |
public function isSent(): bool { |
| 50 |
return $this->reason === self::SENT; |
| 51 |
} |
| 52 |
|
| 53 |
public function getReason(): string { |
| 54 |
return $this->reason; |
| 55 |
} |
| 56 |
} |
| 57 |
|