1 | <?php |
||
14 | class MailResult implements ResultInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var bool |
||
18 | */ |
||
19 | private $valid; |
||
20 | /** |
||
21 | * @var Email |
||
22 | */ |
||
23 | private $email; |
||
24 | /** |
||
25 | * @var \Throwable |
||
26 | */ |
||
27 | private $exception; |
||
28 | |||
29 | 18 | public function __construct(Email $email, bool $valid = true, \Throwable $exception = null) |
|
30 | { |
||
31 | 18 | $this->email = $email; |
|
32 | 18 | $this->valid = $valid; |
|
33 | 18 | $this->exception = $exception; |
|
34 | 18 | } |
|
35 | |||
36 | /** |
||
37 | * Returns the email that was tried to be sent |
||
38 | * @return Email |
||
39 | */ |
||
40 | 5 | public function getEmail(): Email |
|
41 | { |
||
42 | 5 | return $this->email; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * Tells if the MailService that produced this result was properly sent |
||
47 | * @return bool |
||
48 | */ |
||
49 | 11 | public function isValid(): bool |
|
50 | { |
||
51 | 11 | return $this->valid; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * Tells if this Result has an exception. Usually only non-valid result should wrap an exception |
||
56 | * @return bool |
||
57 | */ |
||
58 | 3 | public function hasException(): bool |
|
62 | |||
63 | /** |
||
64 | * Returns the exception wrapped by this Result if any, or null otherwise |
||
65 | * @return \Throwable|null |
||
66 | */ |
||
67 | 3 | public function getException() |
|
71 | |||
72 | /** |
||
73 | * Tells if the email sending was cancelled, usually by a preSend listener |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function isCancelled(): bool |
||
80 | } |
||
81 |