@@ -32,11 +32,11 @@ |
||
32 | 32 | { |
33 | 33 | parent::boot(); |
34 | 34 | |
35 | - static::created(function ($results) { |
|
35 | + static::created(function($results) { |
|
36 | 36 | Cache::forget(self::CACHE_KEY); |
37 | 37 | }); |
38 | 38 | |
39 | - static::deleted(function ($results) { |
|
39 | + static::deleted(function($results) { |
|
40 | 40 | Cache::forget(self::CACHE_KEY); |
41 | 41 | }); |
42 | 42 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('webhooks', function (Blueprint $table) { |
|
15 | + Schema::create('webhooks', function(Blueprint $table) { |
|
16 | 16 | $table->increments('id'); |
17 | 17 | $table->integer('tenant_id')->nullable(); |
18 | 18 | $table->string('url'); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | | The tenant_id field can be used for verification. |
31 | 31 | | |
32 | 32 | */ |
33 | - 'filter' => function ($webhook) { |
|
33 | + 'filter' => function($webhook) { |
|
34 | 34 | return true; |
35 | 35 | }, |
36 | 36 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | | subject data of an event and convert it to a format that will then |
44 | 44 | | be posted to the webhooks. By default, all data is json encoded. |
45 | 45 | */ |
46 | - 'transformer' => function ($eventData) { |
|
46 | + 'transformer' => function($eventData) { |
|
47 | 47 | return json_encode($eventData); |
48 | 48 | }, |
49 | 49 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('webhook_logs', function (Blueprint $table) { |
|
15 | + Schema::create('webhook_logs', function(Blueprint $table) { |
|
16 | 16 | $table->increments('id'); |
17 | 17 | $table->integer('webhook_id')->unsigned()->nullable(); |
18 | 18 | $table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('set null'); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | /** |
35 | 35 | * Create a new job instance. |
36 | 36 | * |
37 | - * @param array|\Illuminate\Support\Collection $webhooks |
|
37 | + * @param \Illuminate\Support\Collection $webhooks |
|
38 | 38 | * @param mixed $eventData |
39 | 39 | */ |
40 | 40 | public function __construct($webhooks, $eventData) |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | $webhook->logs()->orderBy('updated_at', 'desc')->first()->delete(); |
63 | 63 | } |
64 | 64 | $log = new WebhookLog([ |
65 | - 'webhook_id' => $webhook[ 'id' ], |
|
66 | - 'url' => $webhook[ 'url' ], |
|
65 | + 'webhook_id' => $webhook['id'], |
|
66 | + 'url' => $webhook['url'], |
|
67 | 67 | ]); |
68 | - $middleware = Middleware::tap(function (RequestInterface $request, $options) use ($log) { |
|
68 | + $middleware = Middleware::tap(function(RequestInterface $request, $options) use ($log) { |
|
69 | 69 | $log->payload_format = isset($request->getHeader('Content-Type')[0]) ? $request->getHeader('Content-Type')[0] : null; |
70 | 70 | $log->payload = $request->getBody()->getContents(); |
71 | - }, function ($request, $options, Promise $response) use ($log) { |
|
72 | - $response->then(function (ResponseInterface $response) use ($log) { |
|
71 | + }, function($request, $options, Promise $response) use ($log) { |
|
72 | + $response->then(function(ResponseInterface $response) use ($log) { |
|
73 | 73 | $log->status = $response->getStatusCode(); |
74 | 74 | $log->response = $response->getBody()->getContents(); |
75 | 75 | $log->response_format = $log->payload_format = isset($response->getHeader('Content-Type')[0]) ? $response->getHeader('Content-Type')[0] : null; |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | }); |
79 | 79 | }); |
80 | 80 | |
81 | - $client->post($webhook[ 'url' ], [ |
|
81 | + $client->post($webhook['url'], [ |
|
82 | 82 | 'body' => $this->eventData, |
83 | 83 | 'handler' => $middleware($client->getConfig('handler')), |
84 | 84 | ]); |
85 | 85 | } else { |
86 | - $client->post($webhook[ 'url' ], [ |
|
86 | + $client->post($webhook['url'], [ |
|
87 | 87 | 'body' => $this->eventData, |
88 | 88 | 'verify' => false, |
89 | 89 | 'timeout' => 10, |
@@ -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.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.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 | } |
@@ -201,15 +201,15 @@ discard block |
||
201 | 201 | */ |
202 | 202 | protected function registerCommands() |
203 | 203 | { |
204 | - $this->app[ 'hook.list' ] = $this->app->share(function () { |
|
204 | + $this->app['hook.list'] = $this->app->share(function() { |
|
205 | 205 | return new ListWebhooks(); |
206 | 206 | }); |
207 | 207 | |
208 | - $this->app[ 'hook.add' ] = $this->app->share(function () { |
|
208 | + $this->app['hook.add'] = $this->app->share(function() { |
|
209 | 209 | return new AddWebhook(); |
210 | 210 | }); |
211 | 211 | |
212 | - $this->app[ 'hook.delete' ] = $this->app->share(function () { |
|
212 | + $this->app['hook.delete'] = $this->app->share(function() { |
|
213 | 213 | return new DeleteWebhook(); |
214 | 214 | }); |
215 | 215 |
@@ -37,10 +37,10 @@ |
||
37 | 37 | try { |
38 | 38 | $hook->save(); |
39 | 39 | $this->info('The webhook was saved successfully.'); |
40 | - $this->info('Event: '.$hook->event); |
|
41 | - $this->info('URL: '.$hook->url); |
|
40 | + $this->info('Event: ' . $hook->event); |
|
41 | + $this->info('URL: ' . $hook->url); |
|
42 | 42 | } catch (Exception $e) { |
43 | - $this->error("The webhook couldn't be added to the database ".$e->getMessage()); |
|
43 | + $this->error("The webhook couldn't be added to the database " . $e->getMessage()); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | $id = $this->argument('id'); |
33 | 33 | $hook = Webhook::find($id); |
34 | 34 | if ($hook === null) { |
35 | - $this->error('Webhook with ID '.$id.' could not be found.'); |
|
35 | + $this->error('Webhook with ID ' . $id . ' could not be found.'); |
|
36 | 36 | } else { |
37 | 37 | $hook->delete(); |
38 | 38 | $this->info('The webhook was deleted successfully.'); |