Completed
Pull Request — master (#300)
by
unknown
16s
created
src/helpers.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use Intervention\Image\ImageManager;
4 4
 
5
-if (!function_exists('captcha')) {
5
+if ( ! function_exists('captcha')) {
6 6
     /**
7 7
      * @param string $config
8 8
      * @return array|ImageManager|mixed
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     }
15 15
 }
16 16
 
17
-if (!function_exists('captcha_src')) {
17
+if ( ! function_exists('captcha_src')) {
18 18
     /**
19 19
      * @param string $config
20 20
      * @return string
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     }
26 26
 }
27 27
 
28
-if (!function_exists('captcha_img')) {
28
+if ( ! function_exists('captcha_img')) {
29 29
 
30 30
     /**
31 31
      * @param string $config
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     }
38 38
 }
39 39
 
40
-if (!function_exists('captcha_check')) {
40
+if ( ! function_exists('captcha_check')) {
41 41
     /**
42 42
      * @param string $value
43 43
      * @return bool
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     }
49 49
 }
50 50
 
51
-if (!function_exists('captcha_api_check')) {
51
+if ( ! function_exists('captcha_api_check')) {
52 52
     /**
53 53
      * @param string $value
54 54
      * @param string $key
Please login to merge, or discard this patch.
src/CaptchaServiceProvider.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
     {
22 22
         // Publish configuration files
23 23
         $this->publishes([
24
-            __DIR__ . '/../config/captcha.php' => config_path('captcha.php')
24
+            __DIR__.'/../config/captcha.php' => config_path('captcha.php')
25 25
         ], 'config');
26 26
 
27 27
         // HTTP routing
28
-        if(!config('captcha.disable')){
28
+        if ( ! config('captcha.disable')) {
29 29
             if (strpos($this->app->version(), 'Lumen') !== false) {
30 30
                 /* @var Router $router */
31 31
                 $router = $this->app;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             } else {
35 35
                 /* @var Router $router */
36 36
                 $router = $this->app['router'];
37
-                if ((double)$this->app->version() >= 5.2) {
37
+                if ((double) $this->app->version() >= 5.2) {
38 38
                     $router->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web');
39 39
                     $router->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web');
40 40
                 } else {
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
         $validator = $this->app['validator'];
49 49
 
50 50
         // Validator extensions
51
-        $validator->extend('captcha', function ($attribute, $value, $parameters) {
51
+        $validator->extend('captcha', function($attribute, $value, $parameters) {
52 52
             return config('captcha.disable') || ($value && captcha_check($value));
53 53
         });
54 54
 
55 55
         // Validator extensions
56
-        $validator->extend('captcha_api', function ($attribute, $value, $parameters) {
56
+        $validator->extend('captcha_api', function($attribute, $value, $parameters) {
57 57
             return config('captcha.disable') || ($value && captcha_api_check($value, $parameters[0], $parameters[1] ?? 'default'));
58 58
         });
59 59
     }
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
     {
68 68
         // Merge configs
69 69
         $this->mergeConfigFrom(
70
-            __DIR__ . '/../config/captcha.php',
70
+            __DIR__.'/../config/captcha.php',
71 71
             'captcha'
72 72
         );
73 73
 
74 74
         // Bind captcha
75
-        $this->app->bind('captcha', function ($app) {
75
+        $this->app->bind('captcha', function($app) {
76 76
             return new Captcha(
77 77
                 $app['Illuminate\Filesystem\Filesystem'],
78 78
                 $app['Illuminate\Contracts\Config\Repository'],
Please login to merge, or discard this patch.
src/Captcha.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         $this->backgrounds = $this->files->files(__DIR__.'/../assets/backgrounds');
255 255
         $this->fonts       = $this->files->files($this->fontsDirectory);
256 256
 
257
-        $this->fonts = array_map(function (SplFileInfo $file) {
257
+        $this->fonts = array_map(function(SplFileInfo $file) {
258 258
             return $file->getPathName();
259 259
         }, $this->fonts);
260 260
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         foreach (str_split($this->text) as $key => $char) {
367 367
             $marginLeft = $this->textLeftPadding + ($key * ($this->image->width() - $this->textLeftPadding) / strlen($this->text));
368 368
 
369
-            $this->image->text($char, $marginLeft, $marginTop, function (FontFactory $font) {
369
+            $this->image->text($char, $marginLeft, $marginTop, function(FontFactory $font) {
370 370
                 $font->file($this->font());
371 371
                 $font->size($this->fontSize());
372 372
                 $font->color($this->fontColor());
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
      */
405 405
     private function fontColor(): string
406 406
     {
407
-        if (! empty($this->fontColors)) {
407
+        if ( ! empty($this->fontColors)) {
408 408
             $color = $this->fontColors[rand(0, count($this->fontColors) - 1)];
409 409
         } else {
410 410
             $color = '#'.str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     private function lines()
432 432
     {
433 433
         for ($i = 0; $i <= $this->lines; $i++) {
434
-            $this->image->drawLine(function (LineFactory $line) use ($i) {
434
+            $this->image->drawLine(function(LineFactory $line) use ($i) {
435 435
                 $line->from(rand(0, $this->image->width()) + $i * rand(0, $this->image->height()),
436 436
                     rand(0, $this->image->height()));
437 437
                 $line->to(rand(0, $this->image->width()), rand(0, $this->image->height()));
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
      */
452 452
     public function check(string $value): bool
453 453
     {
454
-        if (! $this->session->has('captcha')) {
454
+        if ( ! $this->session->has('captcha')) {
455 455
             return false;
456 456
         }
457 457
 
@@ -459,12 +459,12 @@  discard block
 block discarded – undo
459 459
         $sensitive = $this->session->get('captcha.sensitive');
460 460
         $encrypt   = $this->session->get('captcha.encrypt');
461 461
 
462
-        if (! Cache::pull($this->get_cache_key($key))) {
462
+        if ( ! Cache::pull($this->get_cache_key($key))) {
463 463
             $this->session->remove('captcha');
464 464
             return false;
465 465
         }
466 466
 
467
-        if (! $sensitive) {
467
+        if ( ! $sensitive) {
468 468
             $value = $this->str->lower($value);
469 469
         }
470 470
 
@@ -500,13 +500,13 @@  discard block
 block discarded – undo
500 500
      */
501 501
     public function check_api($value, $key, $config = 'default'): bool
502 502
     {
503
-        if (! Cache::pull($this->get_cache_key($key))) {
503
+        if ( ! Cache::pull($this->get_cache_key($key))) {
504 504
             return false;
505 505
         }
506 506
 
507 507
         $this->configure($config);
508 508
 
509
-        if (! $this->sensitive) {
509
+        if ( ! $this->sensitive) {
510 510
             $value = $this->str->lower($value);
511 511
         }
512 512
         if ($this->encrypt) {
Please login to merge, or discard this patch.