Completed
Push — master ( 3eb43d...9c04b9 )
by Marcel
06:27 queued 04:12
created
src/database/2015_10_29_000000_captain_hook_setup_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/database/2015_10_29_000001_captain_hook_setup_logs_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/Mpociot/CaptainHook/Commands/AddWebhook.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Mpociot/CaptainHook/Commands/DeleteWebhook.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
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.');
Please login to merge, or discard this patch.
src/Mpociot/CaptainHook/Webhook.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,16 +31,16 @@
 block discarded – undo
31 31
     {
32 32
         parent::boot();
33 33
 
34
-        static::created(function ($results) {
34
+        static::created(function($results) {
35 35
             Cache::forget(self::CACHE_KEY);
36 36
         });
37 37
 
38 38
 
39
-        static::updated(function ($results) {
39
+        static::updated(function($results) {
40 40
             Cache::forget(self::CACHE_KEY);
41 41
         });
42 42
 
43
-        static::deleted(function ($results) {
43
+        static::deleted(function($results) {
44 44
             Cache::forget(self::CACHE_KEY);
45 45
         });
46 46
     }
Please login to merge, or discard this patch.
src/Mpociot/CaptainHook/CaptainHookServiceProvider.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Mpociot/CaptainHook/Jobs/TriggerWebhooksJob.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     /**
37 37
      * Create a new job instance.
38 38
      *
39
-     * @param array|\Illuminate\Support\Collection $webhooks
39
+     * @param \Illuminate\Support\Collection $webhooks
40 40
      * @param mixed $eventData
41 41
      */
42 42
     public function __construct($webhooks, $eventData)
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     /**
49 49
      * Resolves a string or callable to a valid callable.
50 50
      * @param string|callable $transformer
51
-     * @param $defaultMethodName
51
+     * @param string $defaultMethodName
52 52
      * @return callable
53 53
      */
54 54
     private function resolveCallable($transformer, $defaultMethodName)
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     private function resolveCallable($transformer, $defaultMethodName)
55 55
     {
56 56
         if (is_string($transformer)) {
57
-            return function () use ($transformer, $defaultMethodName) {
57
+            return function() use ($transformer, $defaultMethodName) {
58 58
                 list($class, $method) = Str::parseCallback($transformer, $defaultMethodName);
59 59
 
60 60
                 return call_user_func_array([app($class), $method], func_get_args());
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             return $transformer;
64 64
         }
65 65
 
66
-        return function () {};
66
+        return function() {};
67 67
     }
68 68
 
69 69
     /**
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
                     $webhook->logs()->orderBy('updated_at', 'desc')->first()->delete();
88 88
                 }
89 89
                 $log = new WebhookLog([
90
-                    'webhook_id' => $webhook[ 'id' ],
91
-                    'url' => $webhook[ 'url' ],
90
+                    'webhook_id' => $webhook['id'],
91
+                    'url' => $webhook['url'],
92 92
                 ]);
93
-                $middleware = Middleware::tap(function (RequestInterface $request, $options) use ($log) {
93
+                $middleware = Middleware::tap(function(RequestInterface $request, $options) use ($log) {
94 94
                     $log->payload_format = isset($request->getHeader('Content-Type')[0]) ? $request->getHeader('Content-Type')[0] : null;
95 95
                     $log->payload = $request->getBody()->getContents();
96
-                }, function ($request, $options, PromiseInterface $response) use ($log, $webhook, $responseCallback) {
97
-                    $response->then(function (ResponseInterface $response) use ($log, $webhook, $responseCallback) {
96
+                }, function($request, $options, PromiseInterface $response) use ($log, $webhook, $responseCallback) {
97
+                    $response->then(function(ResponseInterface $response) use ($log, $webhook, $responseCallback) {
98 98
                         $log->status = $response->getStatusCode();
99 99
                         $log->response = $response->getBody()->getContents();
100 100
                         $log->response_format = $log->payload_format = isset($response->getHeader('Content-Type')[0]) ? $response->getHeader('Content-Type')[0] : null;
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
                     });
111 111
                 });
112 112
 
113
-                $client->post($webhook[ 'url' ], [
113
+                $client->post($webhook['url'], [
114 114
                     'exceptions' => false,
115 115
                     'body' => $transformer($this->eventData, $webhook),
116 116
                     'verify' => false,
117 117
                     'handler' => $middleware($client->getConfig('handler')),
118 118
                 ]);
119 119
             } else {
120
-                $client->post($webhook[ 'url' ], [
120
+                $client->post($webhook['url'], [
121 121
                     'exceptions' => false,
122 122
                     'body' => $transformer($this->eventData, $webhook),
123 123
                     'verify' => false,
Please login to merge, or discard this patch.
src/config/config.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     | You can also use the 'Foo\Class@transform' notation if you want.
49 49
     |
50 50
     */
51
-    'transformer' => function ($eventData, $webhook) {
51
+    'transformer' => function($eventData, $webhook) {
52 52
         return json_encode($eventData);
53 53
     },
54 54
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     | You can also use the 'Foo\Class@handle' notation if you want.
66 66
     |
67 67
     */
68
-    'response_callback' => function ($webhook, $response) {
68
+    'response_callback' => function($webhook, $response) {
69 69
         // Handle custom response status codes, ...
70 70
     },
71 71
 
Please login to merge, or discard this patch.