Completed
Push — master ( 29444e...91ce82 )
by MeWebStudio - Muharrem
14s queued 14s
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/Captcha.php 2 patches
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -341,7 +341,9 @@  discard block
 block discarded – undo
341 341
         }
342 342
 
343 343
         $hash = $this->hasher->make($key);
344
-        if($this->encrypt) $hash = Crypt::encrypt($hash);
344
+        if($this->encrypt) {
345
+            $hash = Crypt::encrypt($hash);
346
+        }
345 347
         
346 348
         $this->session->put('captcha', [
347 349
             'sensitive' => $this->sensitive,
@@ -474,7 +476,9 @@  discard block
 block discarded – undo
474 476
             $value = $this->str->lower($value);
475 477
         }
476 478
 
477
-        if($encrypt) $key = Crypt::decrypt($key);
479
+        if($encrypt) {
480
+            $key = Crypt::decrypt($key);
481
+        }
478 482
         $check = $this->hasher->check($value, $key);
479 483
         // if verify pass,remove session
480 484
         if ($check) {
@@ -500,8 +504,12 @@  discard block
 block discarded – undo
500 504
 
501 505
         $this->configure($config);
502 506
 
503
-        if(!$this->sensitive) $value = $this->str->lower($value);
504
-        if($this->encrypt) $key = Crypt::decrypt($key);
507
+        if(!$this->sensitive) {
508
+            $value = $this->str->lower($value);
509
+        }
510
+        if($this->encrypt) {
511
+            $key = Crypt::decrypt($key);
512
+        }
505 513
         return $this->hasher->check($value, $key);
506 514
     }
507 515
 
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         $this->hasher = $hasher;
222 222
         $this->str = $str;
223 223
         $this->characters = config('captcha.characters', ['1', '2', '3', '4', '6', '7', '8', '9']);
224
-        $this->fontsDirectory = config('captcha.fontsDirectory',  dirname(__DIR__) . '/assets/fonts');
224
+        $this->fontsDirectory = config('captcha.fontsDirectory', dirname(__DIR__).'/assets/fonts');
225 225
     }
226 226
 
227 227
     /**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
      */
231 231
     protected function configure($config)
232 232
     {
233
-        if ($this->config->has('captcha.' . $config)) {
234
-            foreach ($this->config->get('captcha.' . $config) as $key => $val) {
233
+        if ($this->config->has('captcha.'.$config)) {
234
+            foreach ($this->config->get('captcha.'.$config) as $key => $val) {
235 235
                 $this->{$key} = $val;
236 236
             }
237 237
         }
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function create(string $config = 'default', bool $api = false)
249 249
     {
250
-        $this->backgrounds = $this->files->files(__DIR__ . '/../assets/backgrounds');
250
+        $this->backgrounds = $this->files->files(__DIR__.'/../assets/backgrounds');
251 251
         $this->fonts = $this->files->files($this->fontsDirectory);
252 252
 
253 253
         if (version_compare(app()->version(), '5.5.0', '>=')) {
254
-            $this->fonts = array_map(function ($file) {
254
+            $this->fonts = array_map(function($file) {
255 255
                 /* @var File $file */
256 256
                 return $file->getPathName();
257 257
             }, $this->fonts);
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         }
347 347
 
348 348
         $hash = $this->hasher->make($key);
349
-        if($this->encrypt) $hash = Crypt::encrypt($hash);
349
+        if ($this->encrypt) $hash = Crypt::encrypt($hash);
350 350
 
351 351
         $this->session->put('captcha', [
352 352
             'sensitive' => $this->sensitive,
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         foreach ($text as $key => $char) {
382 382
             $marginLeft = $this->textLeftPadding + ($key * ($this->image->width() - $this->textLeftPadding) / $this->length);
383 383
 
384
-            $this->image->text($char, $marginLeft, $marginTop, function ($font) {
384
+            $this->image->text($char, $marginLeft, $marginTop, function($font) {
385 385
                 /* @var Font $font */
386 386
                 $font->file($this->font());
387 387
                 $font->size($this->fontSize());
@@ -420,10 +420,10 @@  discard block
 block discarded – undo
420 420
      */
421 421
     protected function fontColor(): string
422 422
     {
423
-        if (!empty($this->fontColors)) {
423
+        if ( ! empty($this->fontColors)) {
424 424
             $color = $this->fontColors[rand(0, count($this->fontColors) - 1)];
425 425
         } else {
426
-            $color = '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
426
+            $color = '#'.str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
427 427
         }
428 428
 
429 429
         return $color;
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
                 rand(0, $this->image->height()),
453 453
                 rand(0, $this->image->width()),
454 454
                 rand(0, $this->image->height()),
455
-                function ($draw) {
455
+                function($draw) {
456 456
                     /* @var Font $draw */
457 457
                     $draw->color($this->fontColor());
458 458
                 }
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
      */
471 471
     public function check(string $value): bool
472 472
     {
473
-        if (!$this->session->has('captcha')) {
473
+        if ( ! $this->session->has('captcha')) {
474 474
             return false;
475 475
         }
476 476
 
@@ -478,11 +478,11 @@  discard block
 block discarded – undo
478 478
         $sensitive = $this->session->get('captcha.sensitive');
479 479
         $encrypt = $this->session->get('captcha.encrypt');
480 480
 
481
-        if (!$sensitive) {
481
+        if ( ! $sensitive) {
482 482
             $value = $this->str->lower($value);
483 483
         }
484 484
 
485
-        if($encrypt) $key = Crypt::decrypt($key);
485
+        if ($encrypt) $key = Crypt::decrypt($key);
486 486
         $check = $this->hasher->check($value, $key);
487 487
         // if verify pass,remove session
488 488
         if ($check) {
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      * @return string
500 500
      */
501 501
     protected function get_cache_key($key) {
502
-        return 'captcha_' . md5($key);
502
+        return 'captcha_'.md5($key);
503 503
     }
504 504
 
505 505
     /**
@@ -512,14 +512,14 @@  discard block
 block discarded – undo
512 512
      */
513 513
     public function check_api($value, $key, $config = 'default'): bool
514 514
     {
515
-        if (!Cache::pull($this->get_cache_key($key))) {
515
+        if ( ! Cache::pull($this->get_cache_key($key))) {
516 516
             return false;
517 517
         }
518 518
 
519 519
         $this->configure($config);
520 520
 
521
-        if(!$this->sensitive) $value = $this->str->lower($value);
522
-        if($this->encrypt) $key = Crypt::decrypt($key);
521
+        if ( ! $this->sensitive) $value = $this->str->lower($value);
522
+        if ($this->encrypt) $key = Crypt::decrypt($key);
523 523
         return $this->hasher->check($value, $key);
524 524
     }
525 525
 
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
      */
532 532
     public function src(string $config = 'default'): string
533 533
     {
534
-        return url('captcha/' . $config) . '?' . $this->str->random(8);
534
+        return url('captcha/'.$config).'?'.$this->str->random(8);
535 535
     }
536 536
 
537 537
     /**
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
                 continue;
552 552
             }
553 553
 
554
-            $attrs_str .= $attr . '="' . $value . '" ';
554
+            $attrs_str .= $attr.'="'.$value.'" ';
555 555
         }
556
-        return new HtmlString('<img src="' . $this->src($config) . '" ' . trim($attrs_str) . '>');
556
+        return new HtmlString('<img src="'.$this->src($config).'" '.trim($attrs_str).'>');
557 557
     }
558 558
 }
Please login to merge, or discard this patch.
config/captcha.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 return [
4
-    'disable' => env('CAPTCHA_DISABLE', !str_contains(env('APP_ENV', 'local'), 'prod')),
4
+    'disable' => env('CAPTCHA_DISABLE', ! str_contains(env('APP_ENV', 'local'), 'prod')),
5 5
     'characters' => ['2', '3', '4', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'm', 'n', 'p', 'q', 'r', 't', 'u', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'M', 'N', 'P', 'Q', 'R', 'T', 'U', 'X', 'Y', 'Z'],
6 6
     'default' => [
7 7
         'length' => 9,
Please login to merge, or discard this patch.
src/CaptchaServiceProvider.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  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
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         } else {
34 34
             /* @var Router $router */
35 35
             $router = $this->app['router'];
36
-            if ((double)$this->app->version() >= 5.2) {
36
+            if ((double) $this->app->version() >= 5.2) {
37 37
                 $router->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web');
38 38
                 $router->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web');
39 39
             } else {
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
         $validator = $this->app['validator'];
47 47
 
48 48
         // Validator extensions
49
-        $validator->extend('captcha', function ($attribute, $value, $parameters) {
49
+        $validator->extend('captcha', function($attribute, $value, $parameters) {
50 50
             return config('captcha.disable') || ($value && captcha_check($value));
51 51
         });
52 52
 
53 53
         // Validator extensions
54
-        $validator->extend('captcha_api', function ($attribute, $value, $parameters) {
54
+        $validator->extend('captcha_api', function($attribute, $value, $parameters) {
55 55
             return config('captcha.disable') || ($value && captcha_api_check($value, $parameters[0], $parameters[1] ?? 'default'));
56 56
         });
57 57
     }
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
     {
66 66
         // Merge configs
67 67
         $this->mergeConfigFrom(
68
-            __DIR__ . '/../config/captcha.php',
68
+            __DIR__.'/../config/captcha.php',
69 69
             'captcha'
70 70
         );
71 71
 
72 72
         // Bind captcha
73
-        $this->app->bind('captcha', function ($app) {
73
+        $this->app->bind('captcha', function($app) {
74 74
             return new Captcha(
75 75
                 $app['Illuminate\Filesystem\Filesystem'],
76 76
                 $app['Illuminate\Contracts\Config\Repository'],
Please login to merge, or discard this patch.