1 | <?php |
||
14 | class MailgunAdapter implements ServiceAdapterInterface |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * @var Mailgun |
||
19 | */ |
||
20 | protected $mailgun; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $domain; |
||
26 | |||
27 | /** |
||
28 | * MailgunAdapter constructor. |
||
29 | * |
||
30 | * @param Mailgun $mailgun |
||
31 | * @param string $domain |
||
32 | */ |
||
33 | 1 | public function __construct(Mailgun $mailgun, string $domain) |
|
38 | |||
39 | /** |
||
40 | * @inheritdoc |
||
41 | */ |
||
42 | public function send(Email $email) |
||
46 | |||
47 | /** |
||
48 | * Get message from email to be used by Mailgun API wrapper |
||
49 | * |
||
50 | * @param Email $email |
||
51 | * |
||
52 | * @return array |
||
53 | */ |
||
54 | protected function getMessage(Email $email): array |
||
128 | |||
129 | /** |
||
130 | * Format 'from' to be used by the Mailgun API wrapper |
||
131 | * |
||
132 | * @param Email $email |
||
133 | * |
||
134 | * @return string Formatted 'from' string, Example: 'Bob <[email protected]>' |
||
135 | */ |
||
136 | 2 | protected function formatFrom(Email $email): string |
|
146 | |||
147 | /** |
||
148 | * Format 'to' types to be used by the Mailgun API wrapper |
||
149 | * |
||
150 | * @param string $type To type: 'to', 'cc' or 'bcc' |
||
151 | * @param Email $email |
||
152 | * |
||
153 | * @return string Formatted 'to' of type string, Example: 'Bob <[email protected]>' (separated by commas for multiple recipients) |
||
154 | */ |
||
155 | 3 | protected function formatToType(string $type, Email $email): string |
|
167 | } |
||
168 |