@@ -49,16 +49,16 @@ |
||
49 | 49 | */ |
50 | 50 | public function provideListeners(ListenerAcceptorInterface $listener) |
51 | 51 | { |
52 | - $listener->addListener(NotificationSent::class, function ($e) { |
|
52 | + $listener->addListener(NotificationSent::class, function($e) { |
|
53 | 53 | $this->sent($e); |
54 | 54 | }); |
55 | - $listener->addListener(NotificationDelivered::class, function ($e) { |
|
55 | + $listener->addListener(NotificationDelivered::class, function($e) { |
|
56 | 56 | $this->delivered($e); |
57 | 57 | }); |
58 | - $listener->addListener(NotificationClicked::class, function ($e) { |
|
58 | + $listener->addListener(NotificationClicked::class, function($e) { |
|
59 | 59 | $this->clicked($e); |
60 | 60 | }); |
61 | - $listener->addListener(NotificationFailed::class, function ($e) { |
|
61 | + $listener->addListener(NotificationFailed::class, function($e) { |
|
62 | 62 | $this->failed($e); |
63 | 63 | }); |
64 | 64 |
@@ -49,16 +49,20 @@ |
||
49 | 49 | */ |
50 | 50 | public function provideListeners(ListenerAcceptorInterface $listener) |
51 | 51 | { |
52 | - $listener->addListener(NotificationSent::class, function ($e) { |
|
52 | + $listener->addListener(NotificationSent::class, function ($e) |
|
53 | + { |
|
53 | 54 | $this->sent($e); |
54 | 55 | }); |
55 | - $listener->addListener(NotificationDelivered::class, function ($e) { |
|
56 | + $listener->addListener(NotificationDelivered::class, function ($e) |
|
57 | + { |
|
56 | 58 | $this->delivered($e); |
57 | 59 | }); |
58 | - $listener->addListener(NotificationClicked::class, function ($e) { |
|
60 | + $listener->addListener(NotificationClicked::class, function ($e) |
|
61 | + { |
|
59 | 62 | $this->clicked($e); |
60 | 63 | }); |
61 | - $listener->addListener(NotificationFailed::class, function ($e) { |
|
64 | + $listener->addListener(NotificationFailed::class, function ($e) |
|
65 | + { |
|
62 | 66 | $this->failed($e); |
63 | 67 | }); |
64 | 68 |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | foreach ($this->subscribers as $subscriber) { |
137 | 137 | $provider = $subscriber->getProvider(); |
138 | 138 | |
139 | - if (! $this->project->providerConnected($provider)) { |
|
139 | + if ( ! $this->project->providerConnected($provider)) { |
|
140 | 140 | continue; |
141 | 141 | } |
142 | 142 | |
143 | - if (! isset($partials[$provider])) { |
|
143 | + if ( ! isset($partials[$provider])) { |
|
144 | 144 | $partials[$provider] = []; |
145 | 145 | } |
146 | 146 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function bootListeners() |
204 | 204 | { |
205 | - if (! is_null($this->statisticsStorage)) { |
|
205 | + if ( ! is_null($this->statisticsStorage)) { |
|
206 | 206 | static::$events->useListenerProvider($this->statisticsStorage); |
207 | 207 | } |
208 | 208 | } |
@@ -92,10 +92,14 @@ discard block |
||
92 | 92 | |
93 | 93 | $partials = $this->splitSubscribers(); |
94 | 94 | |
95 | - foreach ($partials as $provider => $subscribers) { |
|
96 | - try { |
|
95 | + foreach ($partials as $provider => $subscribers) |
|
96 | + { |
|
97 | + try |
|
98 | + { |
|
97 | 99 | $this->provider($provider)->send($this->notification, $subscribers); |
98 | - } catch (\RuntimeException $e) { |
|
100 | + } |
|
101 | + catch (\RuntimeException $e) |
|
102 | + { |
|
99 | 103 | static::emit('flush.exception', $e); |
100 | 104 | } |
101 | 105 | } |
@@ -133,20 +137,24 @@ discard block |
||
133 | 137 | $partials = []; |
134 | 138 | |
135 | 139 | /** @var Subscriber $subscriber */ |
136 | - foreach ($this->subscribers as $subscriber) { |
|
140 | + foreach ($this->subscribers as $subscriber) |
|
141 | + { |
|
137 | 142 | $provider = $subscriber->getProvider(); |
138 | 143 | |
139 | - if (! $this->project->providerConnected($provider)) { |
|
144 | + if (! $this->project->providerConnected($provider)) |
|
145 | + { |
|
140 | 146 | continue; |
141 | 147 | } |
142 | 148 | |
143 | - if (! isset($partials[$provider])) { |
|
149 | + if (! isset($partials[$provider])) |
|
150 | + { |
|
144 | 151 | $partials[$provider] = []; |
145 | 152 | } |
146 | 153 | |
147 | 154 | $partials[$provider][] = $subscriber; |
148 | 155 | |
149 | - if ($this->payloadStorage) { |
|
156 | + if ($this->payloadStorage) |
|
157 | + { |
|
150 | 158 | $this->payloadStorage->assignNotificationToSubscriber( |
151 | 159 | $subscriber, |
152 | 160 | $this->notification, |
@@ -165,11 +173,13 @@ discard block |
||
165 | 173 | */ |
166 | 174 | protected function validate() |
167 | 175 | { |
168 | - if (is_null($this->notification)) { |
|
176 | + if (is_null($this->notification)) |
|
177 | + { |
|
169 | 178 | throw new \RuntimeException("Notification wasn't set."); |
170 | 179 | } |
171 | 180 | |
172 | - if (is_null($this->subscribers)) { |
|
181 | + if (is_null($this->subscribers)) |
|
182 | + { |
|
173 | 183 | throw new \RuntimeException('No subscribers set.'); |
174 | 184 | } |
175 | 185 | } |
@@ -202,7 +212,8 @@ discard block |
||
202 | 212 | */ |
203 | 213 | protected function bootListeners() |
204 | 214 | { |
205 | - if (! is_null($this->statisticsStorage)) { |
|
215 | + if (! is_null($this->statisticsStorage)) |
|
216 | + { |
|
206 | 217 | static::$events->useListenerProvider($this->statisticsStorage); |
207 | 218 | } |
208 | 219 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | $this->flush( |
67 | 67 | $subscribers, |
68 | - function (Response $response) use ($notification) { |
|
68 | + function(Response $response) use ($notification) { |
|
69 | 69 | try { |
70 | 70 | if ($response->getStatusCode() != 201) { |
71 | 71 | $response = json_decode($response->getBody()); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | Driver::emit(new NotificationFailed($notification)); |
83 | 83 | } |
84 | 84 | }, |
85 | - function () use ($notification) { |
|
85 | + function() use ($notification) { |
|
86 | 86 | Driver::emit(new NotificationFailed($notification)); |
87 | 87 | } |
88 | 88 | ); |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected static function initBrowser(array $config) |
33 | 33 | { |
34 | - if (static::$browser) { |
|
34 | + if (static::$browser) |
|
35 | + { |
|
35 | 36 | return; |
36 | 37 | } |
37 | 38 | |
@@ -65,12 +66,16 @@ discard block |
||
65 | 66 | |
66 | 67 | $this->flush( |
67 | 68 | $subscribers, |
68 | - function (Response $response) use ($notification) { |
|
69 | - try { |
|
70 | - if ($response->getStatusCode() != 201) { |
|
69 | + function (Response $response) use ($notification) |
|
70 | + { |
|
71 | + try |
|
72 | + { |
|
73 | + if ($response->getStatusCode() != 201) |
|
74 | + { |
|
71 | 75 | $response = json_decode($response->getBody()); |
72 | 76 | |
73 | - if (json_last_error() !== JSON_ERROR_NONE) { |
|
77 | + if (json_last_error() !== JSON_ERROR_NONE) |
|
78 | + { |
|
74 | 79 | throw new \Exception('Firefox: bad json'); |
75 | 80 | } |
76 | 81 | |
@@ -78,11 +83,14 @@ discard block |
||
78 | 83 | } |
79 | 84 | |
80 | 85 | Driver::emit(new NotificationSent($notification)); |
81 | - } catch (\Exception $e) { |
|
86 | + } |
|
87 | + catch (\Exception $e) |
|
88 | + { |
|
82 | 89 | Driver::emit(new NotificationFailed($notification)); |
83 | 90 | } |
84 | 91 | }, |
85 | - function () use ($notification) { |
|
92 | + function () use ($notification) |
|
93 | + { |
|
86 | 94 | Driver::emit(new NotificationFailed($notification)); |
87 | 95 | } |
88 | 96 | ); |
@@ -100,7 +108,8 @@ discard block |
||
100 | 108 | $headers = static::$headers; |
101 | 109 | $content = ''; |
102 | 110 | |
103 | - foreach ($subscribers as $subscriber) { |
|
111 | + foreach ($subscribers as $subscriber) |
|
112 | + { |
|
104 | 113 | $headers['Content-Length'] = strlen($content); |
105 | 114 | |
106 | 115 | yield new Request('POST', $this->getUrl($subscriber), $headers, $content); |