Test Failed
Push — master ( 28f62a...92052f )
by Antonio Carlos
10:17
created
src/migrations/2014_02_01_311070_create_firewall_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('firewall', function (Blueprint $table) {
16
+        Schema::create('firewall', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
 
19 19
             $table->string('ip_address', 39)->unique()->index();
Please login to merge, or discard this patch.
src/Listeners/NotifyAdmins.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     private function getNotifiableUsers()
15 15
     {
16
-        return collect(config('firewall.notifications.users.emails'))->map(function ($item) {
16
+        return collect(config('firewall.notifications.users.emails'))->map(function($item) {
17 17
             if (class_exists($class = config('firewall.notifications.users.model'))) {
18 18
                 $model = app($class);
19 19
 
Please login to merge, or discard this patch.
src/Notifications/Channels/Slack.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,21 +55,21 @@
 block discarded – undo
55 55
             })
56 56
             ->attachment(function ($attachment) use ($item) {
57 57
                 $attachment->title($title = config('firewall.notifications.message.uri.title'))
58
-                           ->content($item['server']['REQUEST_URI']);
58
+                            ->content($item['server']['REQUEST_URI']);
59 59
             })
60 60
             ->attachment(function ($attachment) use ($item) {
61 61
                 $attachment->title(config('firewall.notifications.message.user_agent.title'))
62
-                           ->content($item['userAgent']);
62
+                            ->content($item['userAgent']);
63 63
             })
64 64
             ->attachment(function ($attachment) use ($item) {
65 65
                 $attachment->title(config('firewall.notifications.message.blacklisted.title'))
66
-                           ->content($item['isBlacklisted'] ? 'YES' : 'NO');
66
+                            ->content($item['isBlacklisted'] ? 'YES' : 'NO');
67 67
             });
68 68
 
69 69
         if ($item['geoIp']) {
70 70
             $message->attachment(function ($attachment) use ($item) {
71 71
                 $attachment->title(config('firewall.notifications.message.geolocation.title'))
72
-                           ->fields($this->makeGeolocation($item));
72
+                            ->fields($this->makeGeolocation($item));
73 73
             });
74 74
         }
75 75
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                 config('firewall.notifications.from.icon_emoji')
43 43
             )
44 44
             ->content($this->getMessage($item))
45
-            ->attachment(function ($attachment) use ($item) {
45
+            ->attachment(function($attachment) use ($item) {
46 46
                 $attachment->title(config('firewall.notifications.message.request_count.title'))
47 47
                             ->content(
48 48
                                 sprintf(
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
                                 )
54 54
                             );
55 55
             })
56
-            ->attachment(function ($attachment) use ($item) {
56
+            ->attachment(function($attachment) use ($item) {
57 57
                 $attachment->title($title = config('firewall.notifications.message.uri.title'))
58 58
                            ->content($item['server']['REQUEST_URI']);
59 59
             })
60
-            ->attachment(function ($attachment) use ($item) {
60
+            ->attachment(function($attachment) use ($item) {
61 61
                 $attachment->title(config('firewall.notifications.message.user_agent.title'))
62 62
                            ->content($item['userAgent']);
63 63
             })
64
-            ->attachment(function ($attachment) use ($item) {
64
+            ->attachment(function($attachment) use ($item) {
65 65
                 $attachment->title(config('firewall.notifications.message.blacklisted.title'))
66 66
                            ->content($item['isBlacklisted'] ? 'YES' : 'NO');
67 67
             });
68 68
 
69 69
         if ($item['geoIp']) {
70
-            $message->attachment(function ($attachment) use ($item) {
70
+            $message->attachment(function($attachment) use ($item) {
71 71
                 $attachment->title(config('firewall.notifications.message.geolocation.title'))
72 72
                            ->fields($this->makeGeolocation($item));
73 73
             });
Please login to merge, or discard this patch.
src/Repositories/DataRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     {
51 51
         $country = $this->makeCountryFromString($country);
52 52
 
53
-        return $this->ipList()->all()->filter(function ($item) use ($country) {
53
+        return $this->ipList()->all()->filter(function($item) use ($country) {
54 54
             return $item['ip_address'] == $country ||
55 55
                 $this->makeCountryFromString($this->getCountryFromIp($item['ip_address'])) == $country;
56 56
         });
Please login to merge, or discard this patch.
src/Repositories/Message.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@
 block discarded – undo
33 33
      */
34 34
     public function addMessage($message)
35 35
     {
36
-        collect((array) $message)->each(function ($item) {
37
-            collect($item)->flatten()->each(function ($flattened) {
36
+        collect((array) $message)->each(function($item) {
37
+            collect($item)->flatten()->each(function($flattened) {
38 38
                 $this->messageList->push($flattened);
39 39
             });
40 40
         });
Please login to merge, or discard this patch.
src/Vendor/Laravel/ServiceProvider.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     private function registerAttackBlocker()
144 144
     {
145
-        $this->app->singleton('firewall.attackBlocker', function () {
145
+        $this->app->singleton('firewall.attackBlocker', function() {
146 146
             return new AttackBlocker();
147 147
         });
148 148
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      */
153 153
     private function registerCountriesRepository()
154 154
     {
155
-        $this->app->singleton('firewall.countries', function () {
155
+        $this->app->singleton('firewall.countries', function() {
156 156
             return new Countries();
157 157
         });
158 158
     }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     private function registerBlacklistCommand()
166 166
     {
167
-        $this->app->singleton('firewall.blacklist.command', function () {
167
+        $this->app->singleton('firewall.blacklist.command', function() {
168 168
             return new BlacklistCommand();
169 169
         });
170 170
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     private function registerCache()
180 180
     {
181
-        $this->app->singleton('firewall.cache', function () {
181
+        $this->app->singleton('firewall.cache', function() {
182 182
             return new Cache(app('cache'));
183 183
         });
184 184
     }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      */
191 191
     private function registerClearCommand()
192 192
     {
193
-        $this->app->singleton('firewall.clear.command', function () {
193
+        $this->app->singleton('firewall.clear.command', function() {
194 194
             return new ClearCommand();
195 195
         });
196 196
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     private function registerDataRepository()
206 206
     {
207
-        $this->app->singleton('firewall.datarepository', function () {
207
+        $this->app->singleton('firewall.datarepository', function() {
208 208
             return new DataRepository();
209 209
         });
210 210
     }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     private function registerFileSystem()
226 226
     {
227
-        $this->app->singleton('firewall.filesystem', function () {
227
+        $this->app->singleton('firewall.filesystem', function() {
228 228
             return new Filesystem();
229 229
         });
230 230
     }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      */
238 238
     private function registerFirewall()
239 239
     {
240
-        $this->app->singleton('firewall', function ($app) {
240
+        $this->app->singleton('firewall', function($app) {
241 241
             $app['firewall.loaded'] = true;
242 242
 
243 243
             $this->firewall = new Firewall(
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
     private function registerIpAddress()
258 258
     {
259
-        $this->app->singleton('firewall.ipaddress', function () {
259
+        $this->app->singleton('firewall.ipaddress', function() {
260 260
             return new IpAddress();
261 261
         });
262 262
     }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      */
268 268
     private function registerIpList()
269 269
     {
270
-        $this->app->singleton('firewall.iplist', function () {
270
+        $this->app->singleton('firewall.iplist', function() {
271 271
             return new IpList($this->getFirewallModel());
272 272
         });
273 273
     }
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      */
279 279
     private function registerMessageRepository()
280 280
     {
281
-        $this->app->singleton('firewall.messages', function () {
281
+        $this->app->singleton('firewall.messages', function() {
282 282
             return new Message();
283 283
         });
284 284
     }
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
      */
291 291
     private function registerMiddleware()
292 292
     {
293
-        $this->app->singleton('firewall.middleware.blacklist', function () {
293
+        $this->app->singleton('firewall.middleware.blacklist', function() {
294 294
             return new FirewallBlacklist(new Blacklist());
295 295
         });
296 296
 
297
-        $this->app->singleton('firewall.middleware.whitelist', function () {
297
+        $this->app->singleton('firewall.middleware.whitelist', function() {
298 298
             return new FirewallWhitelist(new Whitelist());
299 299
         });
300 300
     }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 
307 307
     private function registerGeoIp()
308 308
     {
309
-        $this->app->singleton('firewall.geoip', function () {
309
+        $this->app->singleton('firewall.geoip', function() {
310 310
             return new GeoIp($this->getConfig('geoip_database_path'));
311 311
         });
312 312
     }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
      */
319 319
     private function registerRemoveCommand()
320 320
     {
321
-        $this->app->singleton('firewall.remove.command', function () {
321
+        $this->app->singleton('firewall.remove.command', function() {
322 322
             return new RemoveCommand();
323 323
         });
324 324
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
      */
333 333
     private function registerReportCommand()
334 334
     {
335
-        $this->app->singleton('firewall.list.command', function () {
335
+        $this->app->singleton('firewall.list.command', function() {
336 336
             return new ReportCommand();
337 337
         });
338 338
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      */
345 345
     private function registerUpdateGeoIpCommand()
346 346
     {
347
-        $this->app->singleton('firewall.updategeoip.command', function () {
347
+        $this->app->singleton('firewall.updategeoip.command', function() {
348 348
             return new UpdateGeoIpCommand();
349 349
         });
350 350
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
      */
359 359
     private function registerWhitelistCommand()
360 360
     {
361
-        $this->app->singleton('firewall.whitelist.command', function () {
361
+        $this->app->singleton('firewall.whitelist.command', function() {
362 362
             return new WhitelistCommand();
363 363
         });
364 364
 
Please login to merge, or discard this patch.
src/Repositories/IpList.php 2 patches
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * Remove the ip address from an array list.
66 66
      *
67
-     * @param $type
67
+     * @param string $type
68 68
      * @param $ip
69 69
      *
70 70
      * @return bool
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      *
92 92
      * @param \Illuminate\Database\Eloquent\Model $ip
93 93
      *
94
-     * @return bool
94
+     * @return boolean|null
95 95
      */
96 96
     private function removeFromDatabaseList($ip)
97 97
     {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     /**
138 138
      * Read a file contents.
139 139
      *
140
-     * @param $file
140
+     * @param string $file
141 141
      *
142 142
      * @return array
143 143
      */
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
     /**
247 247
      * Merge IP lists.
248 248
      *
249
-     * @param $database_ips
250
-     * @param $config_ips
249
+     * @param \Illuminate\Support\Collection $database_ips
250
+     * @param \Illuminate\Support\Collection $config_ips
251 251
      *
252 252
      * @return \Illuminate\Support\Collection
253 253
      */
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      * Add ip or range to array list.
368 368
      *
369 369
      * @param $whitelist
370
-     * @param $ip
370
+     * @param string $ip
371 371
      *
372 372
      * @return array|mixed
373 373
      */
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     /**
477 477
      * Find ip address in all lists.
478 478
      *
479
-     * @param $ip
479
+     * @param string $ip
480 480
      *
481 481
      * @return \Illuminate\Database\Eloquent\Model|null|static
482 482
      */
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
      *
497 497
      * @param $ip
498 498
      *
499
-     * @return \Illuminate\Database\Eloquent\Model
499
+     * @return FirewallModel|null
500 500
      */
501 501
     private function nonDatabaseFind($ip)
502 502
     {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
      * Add ip or range to database.
512 512
      *
513 513
      * @param $whitelist
514
-     * @param $ip
514
+     * @param string $ip
515 515
      *
516 516
      * @return \Illuminate\Database\Eloquent\Model
517 517
      */
Please login to merge, or discard this patch.
Spacing   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
     private function getNonDatabaseIps()
35 35
     {
36 36
         return array_merge_recursive(
37
-            array_map(function ($ip) {
37
+            array_map(function($ip) {
38 38
                 $ip['whitelisted'] = true;
39 39
 
40 40
                 return $ip;
41 41
             }, $this->formatIpArray($this->config()->get('whitelist'))),
42 42
 
43
-            array_map(function ($ip) {
43
+            array_map(function($ip) {
44 44
                 $ip['whitelisted'] = false;
45 45
 
46 46
                 return $ip;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     private function formatIpArray($list)
163 163
     {
164
-        return array_map(function ($ip) {
164
+        return array_map(function($ip) {
165 165
             return ['ip_address' => $ip];
166 166
         }, $this->makeArrayOfIps($list));
167 167
     }
@@ -426,8 +426,7 @@  discard block
 block discarded – undo
426 426
     public function addToProperList($whitelist, $ip)
427 427
     {
428 428
         $this->config()->get('use_database') ?
429
-            $this->addToDatabaseList($whitelist, $ip) :
430
-            $this->addToArrayList($whitelist, $ip);
429
+            $this->addToDatabaseList($whitelist, $ip) : $this->addToArrayList($whitelist, $ip);
431 430
     }
432 431
 
433 432
     /**
@@ -440,8 +439,7 @@  discard block
 block discarded – undo
440 439
     public function delete($ip)
441 440
     {
442 441
         $this->config()->get('use_database') ?
443
-            $this->removeFromDatabaseList($ip) :
444
-            $this->removeFromArrayList($ip);
442
+            $this->removeFromDatabaseList($ip) : $this->removeFromArrayList($ip);
445 443
     }
446 444
 
447 445
     /**
Please login to merge, or discard this patch.
src/Support/IpAddress.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
     /**
61 61
      * Check if an ip v4 is valid.
62 62
      *
63
-     * @param $item
63
+     * @param string $item
64 64
      *
65 65
      * @return bool
66 66
      */
Please login to merge, or discard this patch.
src/Support/AttackBlocker.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     /**
232 232
      * Check for attacks.
233 233
      *
234
-     * @param $ipAddress
234
+     * @param null|string $ipAddress
235 235
      *
236 236
      * @return bool
237 237
      */
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     /**
368 368
      * Make the cache key to record countries.
369 369
      *
370
-     * @param $ipAddress
370
+     * @param string $ipAddress
371 371
      *
372 372
      * @return string|null
373 373
      */
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected function checkExpiration()
111 111
     {
112
-        $this->getEnabledItems()->each(function ($index, $type) {
112
+        $this->getEnabledItems()->each(function($index, $type) {
113 113
             if (($this->now()->diffInSeconds($this->record[$type]['lastRequestAt'])) <= ($this->getMaxSecondsForType($type))) {
114 114
                 return $this->record;
115 115
             }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      */
212 212
     protected function increment()
213 213
     {
214
-        $this->getEnabledItems()->each(function ($index, $type) {
214
+        $this->getEnabledItems()->each(function($index, $type) {
215 215
             $this->save($type, ['requestCount' => $this->record[$type]['requestCount'] + 1]);
216 216
         });
217 217
     }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     protected function isAttack()
225 225
     {
226
-        return $this->getEnabledItems()->filter(function ($index, $type) {
226
+        return $this->getEnabledItems()->filter(function($index, $type) {
227 227
             if (!$this->isWhitelisted($type) && $this->record[$type]['requestCount'] > $this->getMaxRequestCountForType($type)) {
228 228
                 $this->takeAction($this->record[$type]);
229 229
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      */
281 281
     private function loadConfig()
282 282
     {
283
-        $this->enabledItems = collect($this->config()->get('attack_blocker.enabled'))->filter(function ($item) {
283
+        $this->enabledItems = collect($this->config()->get('attack_blocker.enabled'))->filter(function($item) {
284 284
             return $item === true;
285 285
         });
286 286
     }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      */
311 311
     protected function loadRecordItems()
312 312
     {
313
-        $this->getEnabledItems()->each(function ($index, $type) {
313
+        $this->getEnabledItems()->each(function($index, $type) {
314 314
             if (is_null($this->record[$type] = $this->cache()->get($key = $this->makeKeyForType($type, $this->ipAddress)))) {
315 315
                 $this->record[$type] = $this->getEmptyRecord($key, $type);
316 316
             }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         if (!$record['wasNotified'] && $this->config()->get('notifications.enabled')) {
464 464
             $this->save($record['type'], ['wasNotified' => true]);
465 465
 
466
-            collect($this->config()->get('notifications.channels'))->filter(function ($value, $channel) use ($record) {
466
+            collect($this->config()->get('notifications.channels'))->filter(function($value, $channel) use ($record) {
467 467
                 event(new AttackDetected($record, $channel));
468 468
             });
469 469
         }
Please login to merge, or discard this patch.