@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | private function resolveTransformer($transformer) |
54 | 54 | { |
55 | 55 | if (is_string($transformer)) { |
56 | - return function () use ($transformer) { |
|
56 | + return function() use ($transformer) { |
|
57 | 57 | list($class, $method) = Str::parseCallback($transformer, 'transform'); |
58 | 58 | |
59 | 59 | return call_user_func_array([app($class), $method], func_get_args()); |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | $webhook->logs()->orderBy('updated_at', 'desc')->first()->delete(); |
84 | 84 | } |
85 | 85 | $log = new WebhookLog([ |
86 | - 'webhook_id' => $webhook[ 'id' ], |
|
87 | - 'url' => $webhook[ 'url' ], |
|
86 | + 'webhook_id' => $webhook['id'], |
|
87 | + 'url' => $webhook['url'], |
|
88 | 88 | ]); |
89 | - $middleware = Middleware::tap(function (RequestInterface $request, $options) use ($log) { |
|
89 | + $middleware = Middleware::tap(function(RequestInterface $request, $options) use ($log) { |
|
90 | 90 | $log->payload_format = isset($request->getHeader('Content-Type')[0]) ? $request->getHeader('Content-Type')[0] : null; |
91 | 91 | $log->payload = $request->getBody()->getContents(); |
92 | - }, function ($request, $options, PromiseInterface $response) use ($log) { |
|
93 | - $response->then(function (ResponseInterface $response) use ($log) { |
|
92 | + }, function($request, $options, PromiseInterface $response) use ($log) { |
|
93 | + $response->then(function(ResponseInterface $response) use ($log) { |
|
94 | 94 | $log->status = $response->getStatusCode(); |
95 | 95 | $log->response = $response->getBody()->getContents(); |
96 | 96 | $log->response_format = $log->payload_format = isset($response->getHeader('Content-Type')[0]) ? $response->getHeader('Content-Type')[0] : null; |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | }); |
105 | 105 | }); |
106 | 106 | |
107 | - $client->post($webhook[ 'url' ], [ |
|
107 | + $client->post($webhook['url'], [ |
|
108 | 108 | 'exceptions' => false, |
109 | 109 | 'body' => $transformer($this->eventData, $webhook), |
110 | 110 | 'verify' => false, |
111 | 111 | 'handler' => $middleware($client->getConfig('handler')), |
112 | 112 | ]); |
113 | 113 | } else { |
114 | - $client->post($webhook[ 'url' ], [ |
|
114 | + $client->post($webhook['url'], [ |
|
115 | 115 | 'exceptions' => false, |
116 | 116 | 'body' => $transformer($this->eventData, $webhook), |
117 | 117 | 'verify' => false, |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | protected function publishMigration() |
80 | 80 | { |
81 | 81 | $migrations = [ |
82 | - __DIR__.'/../../database/2015_10_29_000000_captain_hook_setup_table.php' => database_path('/migrations/'.date('Y_m_d_His').'_captain_hook_setup_table.php'), |
|
83 | - __DIR__.'/../../database/2015_10_29_000001_captain_hook_setup_logs_table.php' => database_path('/migrations/'.date('Y_m_d_His', strtotime('+1s')).'_captain_hook_setup_logs_table.php'), |
|
82 | + __DIR__ . '/../../database/2015_10_29_000000_captain_hook_setup_table.php' => database_path('/migrations/' . date('Y_m_d_His') . '_captain_hook_setup_table.php'), |
|
83 | + __DIR__ . '/../../database/2015_10_29_000001_captain_hook_setup_logs_table.php' => database_path('/migrations/' . date('Y_m_d_His', strtotime('+1s')) . '_captain_hook_setup_logs_table.php'), |
|
84 | 84 | ]; |
85 | 85 | |
86 | 86 | foreach ($migrations as $migration => $toPath) { |
87 | 87 | preg_match('/_captain_hook_.*\.php/', $migration, $match); |
88 | - $published_migration = glob(database_path('/migrations/*'.$match[0])); |
|
88 | + $published_migration = glob(database_path('/migrations/*' . $match[0])); |
|
89 | 89 | if (count($published_migration) !== 0) { |
90 | 90 | unset($migrations[$migration]); |
91 | 91 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | protected function publishConfig() |
101 | 101 | { |
102 | 102 | $this->publishes([ |
103 | - __DIR__.'/../../config/config.php' => config_path('captain_hook.php'), |
|
103 | + __DIR__ . '/../../config/config.php' => config_path('captain_hook.php'), |
|
104 | 104 | ]); |
105 | 105 | } |
106 | 106 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | protected function registerEventListeners() |
111 | 111 | { |
112 | 112 | foreach ($this->listeners as $eventName) { |
113 | - $this->app[ 'events' ]->listen($eventName, [$this, 'handleEvent']); |
|
113 | + $this->app['events']->listen($eventName, [$this, 'handleEvent']); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | public function setWebhooks($webhooks) |
131 | 131 | { |
132 | 132 | $this->webhooks = $webhooks; |
133 | - $this->getCache()->rememberForever(Webhook::CACHE_KEY, function () { |
|
133 | + $this->getCache()->rememberForever(Webhook::CACHE_KEY, function() { |
|
134 | 134 | return $this->webhooks; |
135 | 135 | }); |
136 | 136 | } |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function getWebhooks() |
142 | 142 | { |
143 | - if (! $this->getCache()->has(Webhook::CACHE_KEY)) { |
|
144 | - $this->getCache()->rememberForever(Webhook::CACHE_KEY, function () { |
|
143 | + if (!$this->getCache()->has(Webhook::CACHE_KEY)) { |
|
144 | + $this->getCache()->rememberForever(Webhook::CACHE_KEY, function() { |
|
145 | 145 | return Webhook::all(); |
146 | 146 | }); |
147 | 147 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $webhooks = $this->getWebhooks()->where('event', $eventName); |
193 | 193 | $webhooks = $webhooks->filter($this->config->get('captain_hook.filter', null)); |
194 | 194 | |
195 | - if (! $webhooks->isEmpty()) { |
|
195 | + if (!$webhooks->isEmpty()) { |
|
196 | 196 | $this->dispatch(new TriggerWebhooksJob($webhooks, $eventData)); |
197 | 197 | } |
198 | 198 | } |
@@ -202,15 +202,15 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function registerCommands() |
204 | 204 | { |
205 | - $this->app[ 'hook.list' ] = $this->app->share(function () { |
|
205 | + $this->app['hook.list'] = $this->app->share(function() { |
|
206 | 206 | return new ListWebhooks(); |
207 | 207 | }); |
208 | 208 | |
209 | - $this->app[ 'hook.add' ] = $this->app->share(function () { |
|
209 | + $this->app['hook.add'] = $this->app->share(function() { |
|
210 | 210 | return new AddWebhook(); |
211 | 211 | }); |
212 | 212 | |
213 | - $this->app[ 'hook.delete' ] = $this->app->share(function () { |
|
213 | + $this->app['hook.delete'] = $this->app->share(function() { |
|
214 | 214 | return new DeleteWebhook(); |
215 | 215 | }); |
216 | 216 |