1 | <?php namespace RuleCom\Notifier\Channels; |
||
7 | class Email implements Channel |
||
8 | { |
||
9 | /** |
||
10 | * @var Client |
||
11 | */ |
||
12 | private $guzzle; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $apiKey; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $subject = ''; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $from = ['name' => '', 'email' => '']; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $to = ['name' => '', 'email' => '']; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | private $content = ['html' => '', 'plain' => '']; |
||
38 | |||
39 | /** |
||
40 | * @var bool |
||
41 | */ |
||
42 | private $debug = false; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | private $logPath; |
||
48 | |||
49 | /** |
||
50 | * @var Logger |
||
51 | */ |
||
52 | private $logger; |
||
53 | |||
54 | public function __construct(Client $guzzle, Logger $logger = null) |
||
59 | |||
60 | /** |
||
61 | * @param string $apiKey |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function apiKey($apiKey) |
||
69 | |||
70 | /** |
||
71 | * @param string $subject |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function subject($subject) |
||
79 | |||
80 | /** |
||
81 | * @param array $from |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function from(array $from) |
||
89 | |||
90 | /** |
||
91 | * @param array $to |
||
92 | * @return $this |
||
93 | */ |
||
94 | public function to(array $to) |
||
99 | |||
100 | /** |
||
101 | * @param array $content |
||
102 | * @return $this |
||
103 | */ |
||
104 | public function content($content) |
||
109 | |||
110 | public function debug($logPath) |
||
116 | /** |
||
117 | * Dispatches notification message to Rule |
||
118 | */ |
||
119 | public function dispatch() |
||
142 | |||
143 | /** |
||
144 | * @return array |
||
145 | */ |
||
146 | private function extractRecipients() |
||
154 | |||
155 | /** |
||
156 | * Fakes dispatch by logging instead |
||
157 | */ |
||
158 | private function fakeDispatch() |
||
168 | } |
||
169 |