Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface Sending
- {
- public function send($email);
- }
- class MailerAdapter implements Sending
- {
- private $transport;
- public function __construct($name = 'Mailgun')
- {
- $this->setTransport($name);
- }
- public function setTransport($name)
- {
- $this->transport = new ($name . 'Transport');
- }
- public function send($email)
- {
- $this->transport->send($email);
- }
- }
- class MailgunTransport implements Sending
- {
- private $mailgun_api;
- public function __construct()
- {
- $this->mailgun_api = Mailgun::create($_ENV['MAILGUN_KEY']);
- }
- public function send($email)
- {
- $this->mailgun_api->send($email);
- }
- }
- class MailjetTransport implements Sending
- {
- private $mailjet_api;
- public function __construct()
- {
- $this->mailjet_api = new mailjet();
- }
- public function send($email)
- {
- $this->mailjet_api->send($email);
- }
- }
- $mailer = new MailerAdapter();
- $mailer->setTransport('Mailgun');
- $mailer->send('mon email');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement