Completed
Push — master ( 56b044...4ce5b3 )
by MeWebStudio - Muharrem
15s
created
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.
src/Captcha.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
         }
278 278
 
279 279
         return $api ? [
280
-	        'sensitive' => $generator['sensitive'],
281
-	        'key'       => $generator['key'],
282
-        	'img'       => $this->image->encode('data-url')->encoded
280
+            'sensitive' => $generator['sensitive'],
281
+            'key'       => $generator['key'],
282
+            'img'       => $this->image->encode('data-url')->encoded
283 283
         ] : $this->image->response('png', $this->quality);
284 284
     }
285 285
 
@@ -300,24 +300,24 @@  discard block
 block discarded – undo
300 300
      */
301 301
     protected function generate()
302 302
     {
303
-	    $bag = [];
304
-	    for($i = 0; $i < $this->length; $i++)
305
-	    {
306
-		    $char = $this->characters[rand(0, count($this->characters) - 1)];
307
-		    $bag[] = $this->sensitive ? $char : $this->str->lower($char);
308
-	    }
309
-
310
-	    $hash = $this->hasher->make(implode('', $bag));
311
-	    $this->session->put('captcha', [
312
-		    'sensitive' => $this->sensitive,
313
-		    'key'       => $hash
314
-	    ]);
315
-
316
-	    return [
317
-		    'value'     => $bag,
318
-		    'sensitive' => $this->sensitive,
319
-		    'key'       => $hash
320
-	    ];
303
+        $bag = [];
304
+        for($i = 0; $i < $this->length; $i++)
305
+        {
306
+            $char = $this->characters[rand(0, count($this->characters) - 1)];
307
+            $bag[] = $this->sensitive ? $char : $this->str->lower($char);
308
+        }
309
+
310
+        $hash = $this->hasher->make(implode('', $bag));
311
+        $this->session->put('captcha', [
312
+            'sensitive' => $this->sensitive,
313
+            'key'       => $hash
314
+        ]);
315
+
316
+        return [
317
+            'value'     => $bag,
318
+            'sensitive' => $this->sensitive,
319
+            'key'       => $hash
320
+        ];
321 321
     }
322 322
 
323 323
     /**
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
      */
326 326
     protected function text()
327 327
     {
328
-	    $marginTop = $this->image->height() / $this->length;
329
-
330
-	    $i = 0;
331
-	    foreach($this->text as $char)
332
-	    {
333
-		    $marginLeft = $this->textLeftPadding +  ($i * ($this->image->width() - $this->textLeftPadding) / $this->length);
334
-
335
-		    $this->image->text($char, $marginLeft, $marginTop, function($font) {
336
-			    $font->file($this->font());
337
-			    $font->size($this->fontSize());
338
-			    $font->color($this->fontColor());
339
-			    $font->align('left');
340
-			    $font->valign('top');
341
-			    $font->angle($this->angle());
342
-		    });
343
-
344
-		    $i++;
345
-	    }
328
+        $marginTop = $this->image->height() / $this->length;
329
+
330
+        $i = 0;
331
+        foreach($this->text as $char)
332
+        {
333
+            $marginLeft = $this->textLeftPadding +  ($i * ($this->image->width() - $this->textLeftPadding) / $this->length);
334
+
335
+            $this->image->text($char, $marginLeft, $marginTop, function($font) {
336
+                $font->file($this->font());
337
+                $font->size($this->fontSize());
338
+                $font->color($this->fontColor());
339
+                $font->align('left');
340
+                $font->valign('top');
341
+                $font->angle($this->angle());
342
+            });
343
+
344
+            $i++;
345
+        }
346 346
     }
347 347
 
348 348
     /**
@@ -416,42 +416,42 @@  discard block
 block discarded – undo
416 416
         return $this->image;
417 417
     }
418 418
 
419
-	/**
420
-	 * Captcha check
421
-	 *
422
-	 * @param $value
423
-	 * @return bool
424
-	 */
425
-	public function check($value)
426
-	{
427
-		if ( ! $this->session->has('captcha'))
428
-		{
429
-			return false;
430
-		}
431
-
432
-		$key = $this->session->get('captcha.key');
433
-		$sensitive = $this->session->get('captcha.sensitive');
434
-
435
-		if ( ! $sensitive)
436
-		{
437
-			$value = $this->str->lower($value);
438
-		}
439
-
440
-		$this->session->remove('captcha');
441
-
442
-		return $this->hasher->check($value, $key);
443
-	}
444
-
445
-	/**
446
-	 * Captcha check
447
-	 *
448
-	 * @param $value
449
-	 * @return bool
450
-	 */
451
-	public function check_api($value, $key)
452
-	{
453
-		return $this->hasher->check($value, $key);
454
-	}
419
+    /**
420
+     * Captcha check
421
+     *
422
+     * @param $value
423
+     * @return bool
424
+     */
425
+    public function check($value)
426
+    {
427
+        if ( ! $this->session->has('captcha'))
428
+        {
429
+            return false;
430
+        }
431
+
432
+        $key = $this->session->get('captcha.key');
433
+        $sensitive = $this->session->get('captcha.sensitive');
434
+
435
+        if ( ! $sensitive)
436
+        {
437
+            $value = $this->str->lower($value);
438
+        }
439
+
440
+        $this->session->remove('captcha');
441
+
442
+        return $this->hasher->check($value, $key);
443
+    }
444
+
445
+    /**
446
+     * Captcha check
447
+     *
448
+     * @param $value
449
+     * @return bool
450
+     */
451
+    public function check_api($value, $key)
452
+    {
453
+        return $this->hasher->check($value, $key);
454
+    }
455 455
 
456 456
     /**
457 457
      * Generate captcha image source
Please login to merge, or discard this patch.