1 | <?php |
||
11 | class Driver |
||
12 | { |
||
13 | use EventsEmitter; |
||
14 | |||
15 | /** |
||
16 | * @var Project |
||
17 | */ |
||
18 | protected $project; |
||
19 | /** |
||
20 | * @var Notification |
||
21 | */ |
||
22 | protected $notification; |
||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $subscribers; |
||
27 | /** |
||
28 | * @var PayloadStorageContract |
||
29 | */ |
||
30 | protected $payloadStorage; |
||
31 | /** |
||
32 | * @var Statistics |
||
33 | */ |
||
34 | protected $statisticsStorage; |
||
35 | |||
36 | /** |
||
37 | * Create a new Driver. |
||
38 | * |
||
39 | * @param Project $project |
||
40 | * @param PayloadStorageContract $payloadStorage |
||
41 | * @param Statistics $statisticsStorage |
||
42 | */ |
||
43 | 8 | public function __construct(Project $project, PayloadStorageContract $payloadStorage = null, Statistics $statisticsStorage = null) |
|
51 | |||
52 | /** |
||
53 | * Boot driver. |
||
54 | */ |
||
55 | 8 | public function boot() |
|
60 | |||
61 | /** |
||
62 | * Send notification. |
||
63 | * |
||
64 | * @param Notification $notification |
||
65 | * @return $this |
||
66 | */ |
||
67 | 5 | public function send(Notification $notification) |
|
73 | |||
74 | /** |
||
75 | * Endpoints to send to. |
||
76 | * |
||
77 | * @param array $subscribers |
||
78 | * @return $this |
||
79 | */ |
||
80 | 5 | public function to(array $subscribers) |
|
86 | |||
87 | /** |
||
88 | * Send notification. |
||
89 | */ |
||
90 | 5 | public function flush() |
|
104 | |||
105 | /** |
||
106 | * Cast provider. |
||
107 | * |
||
108 | * @param string $name |
||
109 | * @return AbstractProvider |
||
110 | * @throws \RuntimeException |
||
111 | */ |
||
112 | 3 | public function provider($name) |
|
116 | |||
117 | /** |
||
118 | * Prepare notifications. |
||
119 | * Split subscribers by their providers and prepare payload. |
||
120 | */ |
||
121 | 4 | protected function splitSubscribers() |
|
150 | |||
151 | /** |
||
152 | * Validate data. |
||
153 | * |
||
154 | * @throws \RuntimeException |
||
155 | */ |
||
156 | 5 | protected function validate() |
|
166 | |||
167 | /** |
||
168 | * Set project manually. |
||
169 | * |
||
170 | * @param Project $project |
||
171 | * @return $this |
||
172 | */ |
||
173 | 1 | public function setProject(Project $project) |
|
179 | |||
180 | /** |
||
181 | * Get project instance. |
||
182 | * |
||
183 | * @return Project |
||
184 | */ |
||
185 | 1 | public function getProject() |
|
189 | |||
190 | /** |
||
191 | * Boot event listeners. |
||
192 | */ |
||
193 | 8 | protected function bootListeners() |
|
199 | } |
||
200 |