1 | <?php |
||
11 | final class EnvelopeFactory |
||
12 | { |
||
13 | /** |
||
14 | * @var \Closure |
||
15 | */ |
||
16 | private $callback; |
||
17 | |||
18 | /** |
||
19 | * @var EmailAddress |
||
20 | */ |
||
21 | private $fallback; |
||
22 | |||
23 | 15 | private function __construct() |
|
26 | |||
27 | /** |
||
28 | * @param EmailAddress $emailAddress |
||
29 | * @return EnvelopeFactory |
||
30 | */ |
||
31 | 3 | public function withFallback(EmailAddress $emailAddress): EnvelopeFactory |
|
37 | |||
38 | /** |
||
39 | * @param MessageInterface $message |
||
40 | * @return EmailAddress |
||
41 | * @throws EnvelopeException |
||
42 | */ |
||
43 | 13 | public function make(MessageInterface $message): EmailAddress |
|
55 | |||
56 | /** |
||
57 | * @param MessageInterface $message |
||
58 | * @return EmailAddress |
||
59 | * @throws EnvelopeException |
||
60 | */ |
||
61 | 9 | private function extractHeader(MessageInterface $message): EmailAddress |
|
74 | |||
75 | /** |
||
76 | * @param MessageInterface $message |
||
77 | * @param string $headerName |
||
78 | * @return EmailAddress |
||
79 | */ |
||
80 | 7 | private function extractFromAddressListHeader(MessageInterface $message, string $headerName): EmailAddress |
|
93 | |||
94 | /** |
||
95 | * @return EnvelopeFactory |
||
96 | */ |
||
97 | 11 | public static function useExtractedHeader(): EnvelopeFactory |
|
103 | |||
104 | /** |
||
105 | * @param EmailAddress $fixedAddress |
||
106 | * @return EnvelopeFactory |
||
107 | */ |
||
108 | 1 | public static function useFixed(EmailAddress $fixedAddress): EnvelopeFactory |
|
116 | |||
117 | /** |
||
118 | * @param \Closure $callback |
||
119 | * @return EnvelopeFactory |
||
120 | */ |
||
121 | 3 | public static function useCallback(\Closure $callback): EnvelopeFactory |
|
127 | } |
||
128 |