1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @package toolkit |
||
5 | */ |
||
6 | |||
7 | /** |
||
8 | * The Exception to be thrown by the Email class. |
||
9 | */ |
||
10 | class EmailException extends Exception |
||
11 | { |
||
12 | } |
||
13 | |||
14 | /** |
||
15 | * The Email class is a factory class to make it possible to send emails using different gateways. |
||
16 | */ |
||
17 | abstract class Email |
||
18 | { |
||
19 | private $gateway; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
20 | |||
21 | /** |
||
22 | * Returns the EmailGateway to send emails with. |
||
23 | * Calling this function multiple times will return unique objects. |
||
24 | * |
||
25 | * @param string $gateway |
||
26 | * The name of the gateway to use. Please only supply if specific |
||
27 | * gateway functions are being used. |
||
28 | * If the gateway is not found, it will throw an EmailException |
||
29 | * @throws Exception |
||
30 | * @return EmailGateway |
||
31 | */ |
||
32 | public static function create($gateway = null) |
||
0 ignored issues
–
show
|
|||
33 | { |
||
34 | $email_gateway_manager = new EmailGatewayManager; |
||
35 | |||
36 | if ($gateway) { |
||
37 | return $email_gateway_manager->create($gateway); |
||
38 | } else { |
||
39 | return $email_gateway_manager->create($email_gateway_manager->getDefaultGateway()); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 |