Completed
Push — master ( 401b54...8a1de3 )
by MeWebStudio - Muharrem
02:02
created
src/Captcha.php 5 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -232,8 +232,7 @@  discard block
 block discarded – undo
232 232
                 $this->height
233 233
             );
234 234
             $this->canvas->insert($this->image);
235
-        }
236
-        else
235
+        } else
237 236
         {
238 237
             $this->image = $this->canvas;
239 238
         }
@@ -351,8 +350,7 @@  discard block
 block discarded – undo
351 350
         if ( ! empty($this->fontColors))
352 351
         {
353 352
             $color = $this->fontColors[rand(0, count($this->fontColors) - 1)];
354
-        }
355
-        else
353
+        } else
356 354
         {
357 355
             $color = [rand(0, 255), rand(0, 255), rand(0, 255)];
358 356
         }
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@
 block discarded – undo
18 18
 use Illuminate\Config\Repository;
19 19
 use Illuminate\Hashing\BcryptHasher as Hasher;
20 20
 use Illuminate\Filesystem\Filesystem;
21
-use Illuminate\Support\Facades\Crypt;
22 21
 use Illuminate\Support\Str;
23 22
 use Intervention\Image\ImageManager;
24 23
 use Illuminate\Session\Store as Session;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -492,7 +492,7 @@
 block discarded – undo
492 492
      * @param null $config
493 493
      * @param array $attrs HTML attributes supplied to the image tag where key is the attribute
494 494
      * and the value is the attribute value
495
-     * @return string
495
+     * @return HtmlString
496 496
      */
497 497
     public function img($config = null, $attrs = [])
498 498
     {
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
         }
284 284
 
285 285
         return $api ? [
286
-	        'sensitive' => $generator['sensitive'],
287
-	        'key'       => $generator['key'],
288
-        	'img'       => $this->image->encode('data-url')->encoded
286
+            'sensitive' => $generator['sensitive'],
287
+            'key'       => $generator['key'],
288
+            'img'       => $this->image->encode('data-url')->encoded
289 289
         ] : $this->image->response('png', $this->quality);
290 290
     }
291 291
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             $key .= '';
320 320
         } else {
321 321
             for ($i = 0; $i < $this->length; $i++) {
322
-            	$char = $characters[rand(0, count($characters) - 1)];
322
+                $char = $characters[rand(0, count($characters) - 1)];
323 323
                 $bag[] = $this->sensitive ? $char : $this->str->lower($char);
324 324
             }
325 325
             $key = implode('', $bag);
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
         ]);
333 333
 
334 334
         return [
335
-        	'value'     => $bag,
336
-	        'sensitive' => $this->sensitive,
337
-	        'key'       => $hash
335
+            'value'     => $bag,
336
+            'sensitive' => $this->sensitive,
337
+            'key'       => $hash
338 338
         ];
339 339
     }
340 340
 
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
      */
344 344
     protected function text()
345 345
     {
346
-	    $marginTop = $this->image->height() / $this->length;
346
+        $marginTop = $this->image->height() / $this->length;
347 347
 
348
-	    $text = $this->text;
349
-	    if (is_string($text)) {
348
+        $text = $this->text;
349
+        if (is_string($text)) {
350 350
             $text = str_split($text);
351 351
         }
352 352
 
@@ -435,26 +435,26 @@  discard block
 block discarded – undo
435 435
         return $this->image;
436 436
     }
437 437
 
438
-	/**
439
-	 * Captcha check
440
-	 *
441
-	 * @param $value
442
-	 * @return bool
443
-	 */
444
-	public function check($value)
445
-	{
446
-		if ( ! $this->session->has('captcha'))
447
-		{
448
-			return false;
449
-		}
438
+    /**
439
+     * Captcha check
440
+     *
441
+     * @param $value
442
+     * @return bool
443
+     */
444
+    public function check($value)
445
+    {
446
+        if ( ! $this->session->has('captcha'))
447
+        {
448
+            return false;
449
+        }
450 450
 
451
-		$key = $this->session->get('captcha.key');
452
-		$sensitive = $this->session->get('captcha.sensitive');
451
+        $key = $this->session->get('captcha.key');
452
+        $sensitive = $this->session->get('captcha.sensitive');
453 453
 
454
-		if ( ! $sensitive)
455
-		{
456
-			$value = $this->str->lower($value);
457
-		}
454
+        if ( ! $sensitive)
455
+        {
456
+            $value = $this->str->lower($value);
457
+        }
458 458
 
459 459
 
460 460
         $res = $this->hasher->check($value, $key);
@@ -464,18 +464,18 @@  discard block
 block discarded – undo
464 464
         }
465 465
 
466 466
         return $res;
467
-	}
468
-
469
-	/**
470
-	 * Captcha check
471
-	 *
472
-	 * @param $value
473
-	 * @return bool
474
-	 */
475
-	public function check_api($value, $key)
476
-	{
477
-		return $this->hasher->check($value, $key);
478
-	}
467
+    }
468
+
469
+    /**
470
+     * Captcha check
471
+     *
472
+     * @param $value
473
+     * @return bool
474
+     */
475
+    public function check_api($value, $key)
476
+    {
477
+        return $this->hasher->check($value, $key);
478
+    }
479 479
 
480 480
     /**
481 481
      * Generate captcha image source
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $this->session = $session;
199 199
         $this->hasher = $hasher;
200 200
         $this->str = $str;
201
-        $this->characters = config('captcha.characters',['1','2','3','4','6','7','8','9']);
201
+        $this->characters = config('captcha.characters', ['1', '2', '3', '4', '6', '7', '8', '9']);
202 202
     }
203 203
 
204 204
     /**
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
      */
208 208
     protected function configure($config)
209 209
     {
210
-        if ($this->config->has('captcha.' . $config))
210
+        if ($this->config->has('captcha.'.$config))
211 211
         {
212
-            foreach($this->config->get('captcha.' . $config) as $key => $val)
212
+            foreach ($this->config->get('captcha.'.$config) as $key => $val)
213 213
             {
214 214
                 $this->{$key} = $val;
215 215
             }
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function create($config = 'default', $api = false)
227 227
     {
228
-        $this->backgrounds = $this->files->files(__DIR__ . '/../assets/backgrounds');
229
-        $this->fonts = $this->files->files(__DIR__ . '/../assets/fonts');
228
+        $this->backgrounds = $this->files->files(__DIR__.'/../assets/backgrounds');
229
+        $this->fonts = $this->files->files(__DIR__.'/../assets/fonts');
230 230
 
231
-        if (app()->version() >= 5.5){
231
+        if (app()->version() >= 5.5) {
232 232
             $this->fonts = array_map(function($file) {
233 233
                 return $file->getPathName();
234 234
             }, $this->fonts);
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
             $text = str_split($text);
351 351
         }
352 352
 
353
-        foreach($text as $key => $char) {
354
-            $marginLeft = $this->textLeftPadding +  ($key * ($this->image->width() - $this->textLeftPadding) / $this->length);
353
+        foreach ($text as $key => $char) {
354
+            $marginLeft = $this->textLeftPadding + ($key * ($this->image->width() - $this->textLeftPadding) / $this->length);
355 355
 
356 356
             $this->image->text($char, $marginLeft, $marginTop, function($font) {
357 357
                 $font->file($this->font());
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
      */
421 421
     protected function lines()
422 422
     {
423
-        for($i = 0; $i <= $this->lines; $i++)
423
+        for ($i = 0; $i <= $this->lines; $i++)
424 424
         {
425 425
             $this->image->line(
426 426
                 rand(0, $this->image->width()) + $i * rand(0, $this->image->height()),
427 427
                 rand(0, $this->image->height()),
428 428
                 rand(0, $this->image->width()),
429 429
                 rand(0, $this->image->height()),
430
-                function ($draw) {
430
+                function($draw) {
431 431
                     $draw->color($this->fontColor());
432 432
                 }
433 433
             );
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
      */
486 486
     public function src($config = null)
487 487
     {
488
-        return url('captcha' . ($config ? '/' . $config : '/default')) . '?' . $this->str->random(8);
488
+        return url('captcha'.($config ? '/'.$config : '/default')).'?'.$this->str->random(8);
489 489
     }
490 490
 
491 491
     /**
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
     public function img($config = null, $attrs = [])
500 500
     {
501 501
         $attrs_str = '';
502
-        foreach($attrs as $attr => $value){
503
-            if ($attr == 'src'){
502
+        foreach ($attrs as $attr => $value) {
503
+            if ($attr == 'src') {
504 504
                 //Neglect src attribute
505 505
                 continue;
506 506
             }
Please login to merge, or discard this patch.
src/helpers.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,23 +36,23 @@
 block discarded – undo
36 36
 }
37 37
 
38 38
 if ( ! function_exists('captcha_check')) {
39
-	/**
40
-	 * @param $value
41
-	 * @return bool
42
-	 */
43
-	function captcha_check($value)
44
-	{
45
-		return app('captcha')->check($value);
46
-	}
39
+    /**
40
+     * @param $value
41
+     * @return bool
42
+     */
43
+    function captcha_check($value)
44
+    {
45
+        return app('captcha')->check($value);
46
+    }
47 47
 }
48 48
 
49 49
 if ( ! function_exists('captcha_api_check')) {
50
-	/**
51
-	 * @param $value
52
-	 * @return bool
53
-	 */
54
-	function captcha_api_check($value, $key)
55
-	{
56
-		return app('captcha')->check_api($value, $key);
57
-	}
50
+    /**
51
+     * @param $value
52
+     * @return bool
53
+     */
54
+    function captcha_api_check($value, $key)
55
+    {
56
+        return app('captcha')->check_api($value, $key);
57
+    }
58 58
 }
Please login to merge, or discard this patch.
src/CaptchaServiceProvider.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,29 +24,29 @@
 block discarded – undo
24 24
 
25 25
         // HTTP routing
26 26
         if (strpos($this->app->version(), 'Lumen') !== false) {
27
-	        $this->app->get('captcha[/api/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptchaApi');
28
-	        $this->app->get('captcha[/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptcha');
27
+            $this->app->get('captcha[/api/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptchaApi');
28
+            $this->app->get('captcha[/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptcha');
29 29
         } else {
30 30
             if ((double) $this->app->version() >= 5.2) {
31
-	            $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web');
32
-	            $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web');
31
+                $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web');
32
+                $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web');
33 33
             } else {
34
-	            $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi');
35
-	            $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha');
34
+                $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi');
35
+                $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha');
36 36
             }
37 37
         }
38 38
 
39
-	    // Validator extensions
40
-	    $this->app['validator']->extend('captcha', function($attribute, $value, $parameters)
41
-	    {
42
-		    return captcha_check($value);
43
-	    });
39
+        // Validator extensions
40
+        $this->app['validator']->extend('captcha', function($attribute, $value, $parameters)
41
+        {
42
+            return captcha_check($value);
43
+        });
44 44
 
45
-	    // Validator extensions
46
-	    $this->app['validator']->extend('captcha_api', function($attribute, $value, $parameters)
47
-	    {
48
-		    return captcha_api_check($value, $parameters[0]);
49
-	    });
45
+        // Validator extensions
46
+        $this->app['validator']->extend('captcha_api', function($attribute, $value, $parameters)
47
+        {
48
+            return captcha_api_check($value, $parameters[0]);
49
+        });
50 50
     }
51 51
 
52 52
     /**
Please login to merge, or discard this patch.
src/CaptchaController.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,32 +11,32 @@
 block discarded – undo
11 11
 class CaptchaController extends Controller
12 12
 {
13 13
 
14
-	/**
15
-	 * get CAPTCHA
16
-	 *
17
-	 * @param \Mews\Captcha\Captcha $captcha
18
-	 * @param string $config
19
-	 * @return \Intervention\Image\ImageManager->response
20
-	 */
21
-	public function getCaptcha(Captcha $captcha, $config = 'default')
22
-	{
23
-		if (ob_get_contents())
24
-		{
25
-			ob_clean();
26
-		}
27
-		return $captcha->create($config);
28
-	}
14
+    /**
15
+     * get CAPTCHA
16
+     *
17
+     * @param \Mews\Captcha\Captcha $captcha
18
+     * @param string $config
19
+     * @return \Intervention\Image\ImageManager->response
20
+     */
21
+    public function getCaptcha(Captcha $captcha, $config = 'default')
22
+    {
23
+        if (ob_get_contents())
24
+        {
25
+            ob_clean();
26
+        }
27
+        return $captcha->create($config);
28
+    }
29 29
 
30
-	/**
31
-	 * get CAPTCHA api
32
-	 *
33
-	 * @param \Mews\Captcha\Captcha $captcha
34
-	 * @param string $config
35
-	 * @return \Intervention\Image\ImageManager->response
36
-	 */
37
-	public function getCaptchaApi(Captcha $captcha, $config = 'default')
38
-	{
39
-		return $captcha->create($config, true);
40
-	}
30
+    /**
31
+     * get CAPTCHA api
32
+     *
33
+     * @param \Mews\Captcha\Captcha $captcha
34
+     * @param string $config
35
+     * @return \Intervention\Image\ImageManager->response
36
+     */
37
+    public function getCaptchaApi(Captcha $captcha, $config = 'default')
38
+    {
39
+        return $captcha->create($config, true);
40
+    }
41 41
 
42 42
 }
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
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
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'],
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
 
7 7
     'default'   => [
8 8
         'length'    => 9,
Please login to merge, or discard this patch.