@@ -36,7 +36,7 @@  | 
                                                    ||
| 36 | 36 | /**  | 
                                                        
| 37 | 37 | * Create a new job instance.  | 
                                                        
| 38 | 38 | *  | 
                                                        
| 39 | - * @param array|\Illuminate\Support\Collection $wekbhooks  | 
                                                        |
| 39 | + * @param \Illuminate\Support\Collection $webhooks  | 
                                                        |
| 40 | 40 | * @param $eventData  | 
                                                        
| 41 | 41 | */  | 
                                                        
| 42 | 42 | public function __construct($webhooks, $eventData)  | 
                                                        
@@ -63,28 +63,28 @@  | 
                                                    ||
| 63 | 63 |          foreach ($this->webhooks as $webhook) { | 
                                                        
| 64 | 64 |              if ($logging) { | 
                                                        
| 65 | 65 | $log = new CaptainHookLog([  | 
                                                        
| 66 | - 'webhook_id' => $webhook[ 'id' ],  | 
                                                        |
| 67 | - 'url' => $webhook[ 'url' ],  | 
                                                        |
| 66 | + 'webhook_id' => $webhook['id'],  | 
                                                        |
| 67 | + 'url' => $webhook['url'],  | 
                                                        |
| 68 | 68 | ]);  | 
                                                        
| 69 | -                $middleware = Middleware::tap(function (RequestInterface $request, $options) use ($log) { | 
                                                        |
| 69 | +                $middleware = Middleware::tap(function(RequestInterface $request, $options) use ($log) { | 
                                                        |
| 70 | 70 |                      $log->payload_format  = isset($request->getHeader('Content-Type')[0]) ? $request->getHeader('Content-Type')[0] : null; | 
                                                        
| 71 | 71 | $log->payload = $request->getBody()->getContents();  | 
                                                        
| 72 | -                }, function ($request, $options, Promise $response) use ($log) { | 
                                                        |
| 73 | -                    $response->then(function (ResponseInterface $response) use ($log) { | 
                                                        |
| 72 | +                }, function($request, $options, Promise $response) use ($log) { | 
                                                        |
| 73 | +                    $response->then(function(ResponseInterface $response) use ($log) { | 
                                                        |
| 74 | 74 | $log->status = $response->getStatusCode();  | 
                                                        
| 75 | 75 | $log->response = $response->getBody()->getContents();  | 
                                                        
| 76 | -                        $log->response_format = $log->payload_format  = isset($response->getHeader('Content-Type')[0]) ? $response->getHeader('Content-Type')[0] : null; | 
                                                        |
| 76 | +                        $log->response_format = $log->payload_format = isset($response->getHeader('Content-Type')[0]) ? $response->getHeader('Content-Type')[0] : null; | 
                                                        |
| 77 | 77 | |
| 78 | 78 | $log->save();  | 
                                                        
| 79 | 79 | });  | 
                                                        
| 80 | 80 | });  | 
                                                        
| 81 | 81 | |
| 82 | - $client->post($webhook[ 'url' ], [  | 
                                                        |
| 82 | + $client->post($webhook['url'], [  | 
                                                        |
| 83 | 83 | 'body' => $this->eventData,  | 
                                                        
| 84 | 84 |                      'handler' => $middleware($client->getConfig('handler')), | 
                                                        
| 85 | 85 | ]);  | 
                                                        
| 86 | 86 |              } else { | 
                                                        
| 87 | - $client->postAsync($webhook[ 'url' ], [  | 
                                                        |
| 87 | + $client->postAsync($webhook['url'], [  | 
                                                        |
| 88 | 88 | 'body' => $this->eventData,  | 
                                                        
| 89 | 89 | 'verify' => false,  | 
                                                        
| 90 | 90 | 'future' => true,  | 
                                                        
@@ -80,12 +80,12 @@ discard block  | 
                                                    ||
| 80 | 80 |      { | 
                                                        
| 81 | 81 | $migrations = [  | 
                                                        
| 82 | 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/' . substr(date('Y_m_d_His'), 0, -1).'1_captain_hook_setup_logs.php'), | 
                                                        |
| 83 | +            __DIR__ . '/../../database/2015_10_29_000001_captain_hook_setup_logs_table.php' => database_path('/migrations/' . substr(date('Y_m_d_His'), 0, -1) . '1_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 | }  | 
                                                        
@@ -141,7 +141,7 @@ discard block  | 
                                                    ||
| 141 | 141 | public function getWebhooks()  | 
                                                        
| 142 | 142 |      { | 
                                                        
| 143 | 143 |          if (!$this->getCache()->has(Webhook::CACHE_KEY)) { | 
                                                        
| 144 | -            $this->getCache()->rememberForever(Webhook::CACHE_KEY, function () { | 
                                                        |
| 144 | +            $this->getCache()->rememberForever(Webhook::CACHE_KEY, function() { | 
                                                        |
| 145 | 145 | return Webhook::all();  | 
                                                        
| 146 | 146 | });  | 
                                                        
| 147 | 147 | }  | 
                                                        
@@ -200,15 +200,15 @@ discard block  | 
                                                    ||
| 200 | 200 | */  | 
                                                        
| 201 | 201 | protected function registerCommands()  | 
                                                        
| 202 | 202 |      { | 
                                                        
| 203 | -        $this->app[ 'hook.list' ] = $this->app->share(function () { | 
                                                        |
| 203 | +        $this->app['hook.list'] = $this->app->share(function() { | 
                                                        |
| 204 | 204 | return new ListWebhooks();  | 
                                                        
| 205 | 205 | });  | 
                                                        
| 206 | 206 | |
| 207 | -        $this->app[ 'hook.add' ] = $this->app->share(function () { | 
                                                        |
| 207 | +        $this->app['hook.add'] = $this->app->share(function() { | 
                                                        |
| 208 | 208 | return new AddWebhook();  | 
                                                        
| 209 | 209 | });  | 
                                                        
| 210 | 210 | |
| 211 | -        $this->app[ 'hook.delete' ] = $this->app->share(function () { | 
                                                        |
| 211 | +        $this->app['hook.delete'] = $this->app->share(function() { | 
                                                        |
| 212 | 212 | return new DeleteWebhook();  | 
                                                        
| 213 | 213 | });  | 
                                                        
| 214 | 214 | |
@@ -12,7 +12,7 @@  | 
                                                    ||
| 12 | 12 | */  | 
                                                        
| 13 | 13 | public function up()  | 
                                                        
| 14 | 14 |      { | 
                                                        
| 15 | -        Schema::create('captain_hook_logs', function (Blueprint $table) { | 
                                                        |
| 15 | +        Schema::create('captain_hook_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'); | 
                                                        
@@ -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 | |