@@ -49,11 +49,15 @@ discard block |
||
| 49 | 49 | $payload = new Payload($notification); |
| 50 | 50 | $payload = json_encode($payload); |
| 51 | 51 | |
| 52 | - foreach ($this->prepareRequests($subscribers, $payload) as $message) { |
|
| 53 | - try { |
|
| 52 | + foreach ($this->prepareRequests($subscribers, $payload) as $message) |
|
| 53 | + { |
|
| 54 | + try |
|
| 55 | + { |
|
| 54 | 56 | $stream->write($message); |
| 55 | 57 | Driver::emit(new NotificationSent($notification)); |
| 56 | - } catch (\Exception $e) { |
|
| 58 | + } |
|
| 59 | + catch (\Exception $e) |
|
| 60 | + { |
|
| 57 | 61 | Driver::emit(new NotificationFailed($notification)); |
| 58 | 62 | } |
| 59 | 63 | } |
@@ -70,10 +74,14 @@ discard block |
||
| 70 | 74 | */ |
| 71 | 75 | protected function prepareRequests($subscribers, $payload = null) |
| 72 | 76 | { |
| 73 | - foreach ($subscribers as $subscriber) { |
|
| 74 | - try { |
|
| 77 | + foreach ($subscribers as $subscriber) |
|
| 78 | + { |
|
| 79 | + try |
|
| 80 | + { |
|
| 75 | 81 | yield chr(0) . chr(0) . chr(32) . pack('H*', $subscriber->getToken()) . chr(0) . chr(strlen($payload)) . $payload; |
| 76 | - } catch (\Exception $e) { |
|
| 82 | + } |
|
| 83 | + catch (\Exception $e) |
|
| 84 | + { |
|
| 77 | 85 | } |
| 78 | 86 | } |
| 79 | 87 | } |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function ensureHttps($image) |
| 14 | 14 | { |
| 15 | - if (! $image) { |
|
| 15 | + if ( ! $image) { |
|
| 16 | 16 | return; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | $parsed = parse_url($image); |
| 20 | 20 | |
| 21 | 21 | if ($parsed['scheme'] == 'https' || |
| 22 | - $parsed['scheme'] == 'ssl' || |
|
| 22 | + $parsed['scheme'] == 'ssl' || |
|
| 23 | 23 | preg_match('/192\.168|localhost|images\.weserv\.nl/', $parsed['host'])) { |
| 24 | 24 | return $image; |
| 25 | 25 | } |
@@ -12,7 +12,8 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function ensureHttps($image) |
| 14 | 14 | { |
| 15 | - if (! $image) { |
|
| 15 | + if (! $image) |
|
| 16 | + { |
|
| 16 | 17 | return; |
| 17 | 18 | } |
| 18 | 19 | |
@@ -20,7 +21,8 @@ discard block |
||
| 20 | 21 | |
| 21 | 22 | if ($parsed['scheme'] == 'https' || |
| 22 | 23 | $parsed['scheme'] == 'ssl' || |
| 23 | - preg_match('/192\.168|localhost|images\.weserv\.nl/', $parsed['host'])) { |
|
| 24 | + preg_match('/192\.168|localhost|images\.weserv\.nl/', $parsed['host'])) |
|
| 25 | + { |
|
| 24 | 26 | return $image; |
| 25 | 27 | } |
| 26 | 28 | |
@@ -38,8 +38,10 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $provider = $this->resolveExtends($name, $options); |
| 40 | 40 | |
| 41 | - if (is_null($provider)) { |
|
| 42 | - switch ($name) { |
|
| 41 | + if (is_null($provider)) |
|
| 42 | + { |
|
| 43 | + switch ($name) |
|
| 44 | + { |
|
| 43 | 45 | case Chrome::NAME: |
| 44 | 46 | $provider = new Chrome($options); |
| 45 | 47 | break; |
@@ -68,7 +70,8 @@ discard block |
||
| 68 | 70 | */ |
| 69 | 71 | protected function resolveExtends($name, array $options) |
| 70 | 72 | { |
| 71 | - if (empty(static::$resolvers[$name])) { |
|
| 73 | + if (empty(static::$resolvers[$name])) |
|
| 74 | + { |
|
| 72 | 75 | return; |
| 73 | 76 | } |
| 74 | 77 | |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | use League\Event\EventInterface; |
| 7 | 7 | use League\Event\ListenerInterface; |
| 8 | 8 | use Notimatica\Driver\StatisticsStorages\AbstractStorage; |
| 9 | -use Notimatica\Driver\StatisticsStoragesFactory; |
|
| 10 | 9 | |
| 11 | 10 | trait EventsEmitter |
| 12 | 11 | { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $statisticsStorage = $this->makeStatisticsStorage(); |
| 34 | 34 | |
| 35 | - if (! is_null($statisticsStorage)) { |
|
| 35 | + if ( ! is_null($statisticsStorage)) { |
|
| 36 | 36 | static::$events->useListenerProvider($statisticsStorage); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | protected function makeStatisticsStorage() |
| 78 | 78 | { |
| 79 | - if (! empty($this->project->config['statistics']['storage'])) { |
|
| 79 | + if ( ! empty($this->project->config['statistics']['storage'])) { |
|
| 80 | 80 | $storage = $this->project->config['statistics']['storage']; |
| 81 | 81 | |
| 82 | 82 | if (class_exists($storage)) return new $storage; |
@@ -32,7 +32,8 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $statisticsStorage = $this->makeStatisticsStorage(); |
| 34 | 34 | |
| 35 | - if (! is_null($statisticsStorage)) { |
|
| 35 | + if (! is_null($statisticsStorage)) |
|
| 36 | + { |
|
| 36 | 37 | static::$events->useListenerProvider($statisticsStorage); |
| 37 | 38 | } |
| 38 | 39 | } |
@@ -76,10 +77,14 @@ discard block |
||
| 76 | 77 | */ |
| 77 | 78 | protected function makeStatisticsStorage() |
| 78 | 79 | { |
| 79 | - if (! empty($this->project->config['statistics']['storage'])) { |
|
| 80 | + if (! empty($this->project->config['statistics']['storage'])) |
|
| 81 | + { |
|
| 80 | 82 | $storage = $this->project->config['statistics']['storage']; |
| 81 | 83 | |
| 82 | - if (class_exists($storage)) return new $storage; |
|
| 84 | + if (class_exists($storage)) |
|
| 85 | + { |
|
| 86 | + return new $storage; |
|
| 87 | + } |
|
| 83 | 88 | } |
| 84 | 89 | |
| 85 | 90 | return null; |