Completed
Pull Request — master (#198)
by
unknown
06:43
created
src/Captcha.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         $this->hasher = $hasher;
211 211
         $this->str = $str;
212 212
         $this->characters = config('captcha.characters', ['1', '2', '3', '4', '6', '7', '8', '9']);
213
-        $this->fontsDirectory = config('captcha.fontsDirectory', __DIR__ . '/../assets/fonts');
213
+        $this->fontsDirectory = config('captcha.fontsDirectory', __DIR__.'/../assets/fonts');
214 214
     }
215 215
 
216 216
     /**
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
      */
220 220
     protected function configure($config)
221 221
     {
222
-        if ($this->config->has('captcha.' . $config)) {
223
-            foreach ($this->config->get('captcha.' . $config) as $key => $val) {
222
+        if ($this->config->has('captcha.'.$config)) {
223
+            foreach ($this->config->get('captcha.'.$config) as $key => $val) {
224 224
                 $this->{$key} = $val;
225 225
             }
226 226
         }
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function create(string $config = 'default', bool $api = false)
238 238
     {
239
-        $this->backgrounds = $this->files->files(__DIR__ . '/../assets/backgrounds');
239
+        $this->backgrounds = $this->files->files(__DIR__.'/../assets/backgrounds');
240 240
         $this->fonts = $this->files->files($this->fontsDirectory);
241 241
 
242 242
         if (version_compare(app()->version(), '5.5.0', '>=')) {
243
-            $this->fonts = array_map(function ($file) {
243
+            $this->fonts = array_map(function($file) {
244 244
                 /* @var File $file */
245 245
                 return $file->getPathName();
246 246
             }, $this->fonts);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         }
289 289
 
290 290
         if ($api) {
291
-            Cache::put('captcha_record_' . $generator['key'], $generator['value'], $this->expire);
291
+            Cache::put('captcha_record_'.$generator['key'], $generator['value'], $this->expire);
292 292
         }
293 293
 
294 294
         return $api ? [
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         foreach ($text as $key => $char) {
365 365
             $marginLeft = $this->textLeftPadding + ($key * ($this->image->width() - $this->textLeftPadding) / $this->length);
366 366
 
367
-            $this->image->text($char, $marginLeft, $marginTop, function ($font) {
367
+            $this->image->text($char, $marginLeft, $marginTop, function($font) {
368 368
                 /* @var Font $font */
369 369
                 $font->file($this->font());
370 370
                 $font->size($this->fontSize());
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
      */
404 404
     protected function fontColor(): string
405 405
     {
406
-        if (!empty($this->fontColors)) {
406
+        if ( ! empty($this->fontColors)) {
407 407
             $color = $this->fontColors[rand(0, count($this->fontColors) - 1)];
408 408
         } else {
409
-            $color = '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
409
+            $color = '#'.str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
410 410
         }
411 411
 
412 412
         return $color;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
                 rand(0, $this->image->height()),
436 436
                 rand(0, $this->image->width()),
437 437
                 rand(0, $this->image->height()),
438
-                function ($draw) {
438
+                function($draw) {
439 439
                     /* @var Font $draw */
440 440
                     $draw->color($this->fontColor());
441 441
                 }
@@ -453,14 +453,14 @@  discard block
 block discarded – undo
453 453
      */
454 454
     public function check(string $value): bool
455 455
     {
456
-        if (!$this->session->has('captcha')) {
456
+        if ( ! $this->session->has('captcha')) {
457 457
             return false;
458 458
         }
459 459
 
460 460
         $key = $this->session->get('captcha.key');
461 461
         $sensitive = $this->session->get('captcha.sensitive');
462 462
 
463
-        if (!$sensitive) {
463
+        if ( ! $sensitive) {
464 464
             $value = $this->str->lower($value);
465 465
         }
466 466
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
      */
483 483
     public function check_api($value, $key): bool
484 484
     {
485
-        if (!Cache::pull('captcha_record_' . $key)) {
485
+        if ( ! Cache::pull('captcha_record_'.$key)) {
486 486
             return false;
487 487
         }
488 488
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
      */
498 498
     public function src(string $config = 'default'): string
499 499
     {
500
-        return url('captcha/' . $config) . '?' . $this->str->random(8);
500
+        return url('captcha/'.$config).'?'.$this->str->random(8);
501 501
     }
502 502
 
503 503
     /**
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
                 continue;
518 518
             }
519 519
 
520
-            $attrs_str .= $attr . '="' . $value . '" ';
520
+            $attrs_str .= $attr.'="'.$value.'" ';
521 521
         }
522
-        return new HtmlString('<img src="' . $this->src($config) . '" ' . trim($attrs_str) . '>');
522
+        return new HtmlString('<img src="'.$this->src($config).'" '.trim($attrs_str).'>');
523 523
     }
524 524
 }
Please login to merge, or discard this patch.