Passed
Pull Request — master (#11)
by Roberto
05:19
created
src/ReCaptchaServiceProvider.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     {
21 21
         $this->addValidationRule();
22 22
         $this->publishes([
23
-            __DIR__ . '/../config/recaptcha.php' => config_path('recaptcha.php'),
23
+            __DIR__.'/../config/recaptcha.php' => config_path('recaptcha.php'),
24 24
         ]);
25 25
     }
26 26
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
 
35 35
         $this->mergeConfigFrom(
36
-            __DIR__ . '/../config/recaptcha.php', 'recaptcha'
36
+            __DIR__.'/../config/recaptcha.php', 'recaptcha'
37 37
         );
38 38
 
39 39
         $this->registerReCaptchaBuilder();
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected function registerReCaptchaBuilder()
48 48
     {
49
-        $this->app->singleton('recaptcha', function ($app) {
50
-            if(config('recaptcha.version') == 'v2') return new ReCaptchaBuilderV2(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'), config('recaptcha.version'));
49
+        $this->app->singleton('recaptcha', function($app) {
50
+            if (config('recaptcha.version') == 'v2') return new ReCaptchaBuilderV2(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'), config('recaptcha.version'));
51 51
             else return new ReCaptchaBuilderInvisible(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'), config('recaptcha.version'));
52 52
         });
53 53
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,8 +47,11 @@
 block discarded – undo
47 47
     protected function registerReCaptchaBuilder()
48 48
     {
49 49
         $this->app->singleton('recaptcha', function ($app) {
50
-            if(config('recaptcha.version') == 'v2') return new ReCaptchaBuilderV2(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'), config('recaptcha.version'));
51
-            else return new ReCaptchaBuilderInvisible(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'), config('recaptcha.version'));
50
+            if(config('recaptcha.version') == 'v2') {
51
+                return new ReCaptchaBuilderV2(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'), config('recaptcha.version'));
52
+            } else {
53
+                return new ReCaptchaBuilderInvisible(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'), config('recaptcha.version'));
54
+            }
52 55
         });
53 56
     }
54 57
 
Please login to merge, or discard this patch.
src/ReCaptchaBuilderInvisible.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
 
14 14
 class ReCaptchaBuilderInvisible extends ReCaptchaBuilder {
15 15
 
16
-	/**
17
-	 * Write HTML <button> tag in your HTML code
18
-	 * Insert before </form> tag
19
-	 */
20
-	public function htmlFormButton($buttonInnerHTML = 'Submit')
21
-	{
22
-		return ($this->version == 'invisible')? '<button class="g-recaptcha" data-sitekey="'.$this->api_site_key.'" data-callback="biscolabLaravelReCaptcha">'.$buttonInnerHTML.'</button>' : '';
23
-	}
16
+    /**
17
+     * Write HTML <button> tag in your HTML code
18
+     * Insert before </form> tag
19
+     */
20
+    public function htmlFormButton($buttonInnerHTML = 'Submit')
21
+    {
22
+        return ($this->version == 'invisible')? '<button class="g-recaptcha" data-sitekey="'.$this->api_site_key.'" data-callback="biscolabLaravelReCaptcha">'.$buttonInnerHTML.'</button>' : '';
23
+    }
24 24
 
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 	 */
20 20
 	public function htmlFormButton($buttonInnerHTML = 'Submit')
21 21
 	{
22
-		return ($this->version == 'invisible')? '<button class="g-recaptcha" data-sitekey="'.$this->api_site_key.'" data-callback="biscolabLaravelReCaptcha">'.$buttonInnerHTML.'</button>' : '';
22
+		return ($this->version == 'invisible') ? '<button class="g-recaptcha" data-sitekey="'.$this->api_site_key.'" data-callback="biscolabLaravelReCaptcha">'.$buttonInnerHTML.'</button>' : '';
23 23
 	}
24 24
 
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
src/ReCaptchaBuilderV2.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
 
14 14
 class ReCaptchaBuilderV2 extends ReCaptchaBuilder {
15 15
 
16
-	/**
17
-	 * Write ReCAPTCHA HTML tag in your FORM
18
-	 * Insert before </form> tag
19
-	 */
20
-	public function htmlFormSnippet()
21
-	{
22
-		return ($this->version == 'v2')? '<div class="g-recaptcha" data-sitekey="'.$this->api_site_key.'"></div>' : '';
23
-	}
16
+    /**
17
+     * Write ReCAPTCHA HTML tag in your FORM
18
+     * Insert before </form> tag
19
+     */
20
+    public function htmlFormSnippet()
21
+    {
22
+        return ($this->version == 'v2')? '<div class="g-recaptcha" data-sitekey="'.$this->api_site_key.'"></div>' : '';
23
+    }
24 24
 
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 	 */
20 20
 	public function htmlFormSnippet()
21 21
 	{
22
-		return ($this->version == 'v2')? '<div class="g-recaptcha" data-sitekey="'.$this->api_site_key.'"></div>' : '';
22
+		return ($this->version == 'v2') ? '<div class="g-recaptcha" data-sitekey="'.$this->api_site_key.'"></div>' : '';
23 23
 	}
24 24
 
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
src/ReCaptchaBuilder.php 3 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -15,66 +15,66 @@  discard block
 block discarded – undo
15 15
 
16 16
 class ReCaptchaBuilder {
17 17
 
18
-	/**
19
-	 * The Site key
20
-	 * please visit https://developers.google.com/recaptcha/docs/start
21
-	 * @var string
22
-	 */
23
-	protected $api_site_key;
24
-
25
-	/**
26
-	 * The Secret key
27
-	 * please visit https://developers.google.com/recaptcha/docs/start	 
28
-	 * @var string
29
-	 */	
30
-	protected $api_secret_key;
31
-
32
-	/**
33
-	 * The chosen ReCAPTCHA version
34
-	 * please visit https://developers.google.com/recaptcha/docs/start	 
35
-	 * @var string
36
-	 */	
37
-	protected $version;
38
-
39
-	/**
40
-	 * Whether is true the ReCAPTCHA is inactive
41
-	 * @var boolean
42
-	 */	
43
-	protected $skip_by_ip = false;
44
-
45
-	/**
46
-	 * The API request URI
47
-	 */
48
-	protected $api_url = 'https://www.google.com/recaptcha/api/siteverify';
49
-
50
-	public function __construct($api_site_key, $api_secret_key, $version = 'v2')
51
-	{
52
-		$this->api_site_key		= $api_site_key;
53
-		$this->api_secret_key	= $api_secret_key;
54
-		$this->version 			= $version;
55
-		$this->skip_by_ip 		= self::skipByIp();
56
-	}
18
+    /**
19
+     * The Site key
20
+     * please visit https://developers.google.com/recaptcha/docs/start
21
+     * @var string
22
+     */
23
+    protected $api_site_key;
24
+
25
+    /**
26
+     * The Secret key
27
+     * please visit https://developers.google.com/recaptcha/docs/start	 
28
+     * @var string
29
+     */	
30
+    protected $api_secret_key;
31
+
32
+    /**
33
+     * The chosen ReCAPTCHA version
34
+     * please visit https://developers.google.com/recaptcha/docs/start	 
35
+     * @var string
36
+     */	
37
+    protected $version;
38
+
39
+    /**
40
+     * Whether is true the ReCAPTCHA is inactive
41
+     * @var boolean
42
+     */	
43
+    protected $skip_by_ip = false;
44
+
45
+    /**
46
+     * The API request URI
47
+     */
48
+    protected $api_url = 'https://www.google.com/recaptcha/api/siteverify';
49
+
50
+    public function __construct($api_site_key, $api_secret_key, $version = 'v2')
51
+    {
52
+        $this->api_site_key		= $api_site_key;
53
+        $this->api_secret_key	= $api_secret_key;
54
+        $this->version 			= $version;
55
+        $this->skip_by_ip 		= self::skipByIp();
56
+    }
57 57
 	
58
-	/**
59
-	 * Write script HTML tag in you HTML code
60
-	 * Insert before </head> tag
61
-	 *
62
-	 * @param $formId required if you are using invisible ReCaptcha
63
-	 */
64
-	public function htmlScriptTagJsApi($formId = '')
65
-	{
66
-		if($this->skip_by_ip) return '';
67
-		$html = "<script src='https://www.google.com/recaptcha/api.js' async defer></script>";
68
-		if($this->version != 'v2'){
69
-			if(!$formId) throw new Exception("formId required", 1);
70
-			$html.= '<script>
58
+    /**
59
+     * Write script HTML tag in you HTML code
60
+     * Insert before </head> tag
61
+     *
62
+     * @param $formId required if you are using invisible ReCaptcha
63
+     */
64
+    public function htmlScriptTagJsApi($formId = '')
65
+    {
66
+        if($this->skip_by_ip) return '';
67
+        $html = "<script src='https://www.google.com/recaptcha/api.js' async defer></script>";
68
+        if($this->version != 'v2'){
69
+            if(!$formId) throw new Exception("formId required", 1);
70
+            $html.= '<script>
71 71
 		       function biscolabLaravelReCaptcha(token) {
72 72
 		         document.getElementById("'.$formId.'").submit();
73 73
 		       }
74 74
 		     </script>';
75
-		}
76
-		return $html;
77
-	}
75
+        }
76
+        return $html;
77
+    }
78 78
 
79 79
     /**
80 80
      * Call out to reCAPTCHA and process the response
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function validate($response)
87 87
     {
88
-    	if($this->skip_by_ip) {
89
-    		return true;
90
-    	} 
88
+        if($this->skip_by_ip) {
89
+            return true;
90
+        } 
91 91
 
92 92
         $params = http_build_query([
93 93
             'secret'   => $this->api_secret_key,
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      * @return boolean     
122 122
      */
123 123
     public static function skipByIp(){
124
-    	$skip_ip = (config('recaptcha.skip_ip'))? config('recaptcha.skip_ip') : [];
125
-    	return (in_array(request()->ip(), $skip_ip));
124
+        $skip_ip = (config('recaptcha.skip_ip'))? config('recaptcha.skip_ip') : [];
125
+        return (in_array(request()->ip(), $skip_ip));
126 126
     }
127 127
 }
128 128
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 
50 50
 	public function __construct($api_site_key, $api_secret_key, $version = 'v2')
51 51
 	{
52
-		$this->api_site_key		= $api_site_key;
53
-		$this->api_secret_key	= $api_secret_key;
54
-		$this->version 			= $version;
55
-		$this->skip_by_ip 		= self::skipByIp();
52
+		$this->api_site_key = $api_site_key;
53
+		$this->api_secret_key = $api_secret_key;
54
+		$this->version = $version;
55
+		$this->skip_by_ip = self::skipByIp();
56 56
 	}
57 57
 	
58 58
 	/**
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function htmlScriptTagJsApi($formId = '')
65 65
 	{
66
-		if($this->skip_by_ip) return '';
66
+		if ($this->skip_by_ip) return '';
67 67
 		$html = "<script src='https://www.google.com/recaptcha/api.js' async defer></script>";
68
-		if($this->version != 'v2'){
69
-			if(!$formId) throw new Exception("formId required", 1);
70
-			$html.= '<script>
68
+		if ($this->version != 'v2') {
69
+			if (!$formId) throw new Exception("formId required", 1);
70
+			$html .= '<script>
71 71
 		       function biscolabLaravelReCaptcha(token) {
72 72
 		         document.getElementById("'.$formId.'").submit();
73 73
 		       }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function validate($response)
87 87
     {
88
-    	if($this->skip_by_ip) {
88
+    	if ($this->skip_by_ip) {
89 89
     		return true;
90 90
     	} 
91 91
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             'response' => $response,
96 96
         ]);
97 97
 
98
-        $url = $this->api_url. '?' . $params;
98
+        $url = $this->api_url.'?'.$params;
99 99
 
100 100
         if (function_exists('curl_version')) {
101 101
             $curl = curl_init($url);
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         } else {
108 108
             $curl_response = file_get_contents($url);
109 109
         }
110
-        if (is_null($curl_response) || empty( $curl_response )) {
110
+        if (is_null($curl_response) || empty($curl_response)) {
111 111
             return false;
112 112
         }
113 113
         $response = json_decode(trim($curl_response), true);
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
      *
121 121
      * @return boolean     
122 122
      */
123
-    public static function skipByIp(){
124
-    	$skip_ip = (config('recaptcha.skip_ip'))? config('recaptcha.skip_ip') : [];
123
+    public static function skipByIp() {
124
+    	$skip_ip = (config('recaptcha.skip_ip')) ? config('recaptcha.skip_ip') : [];
125 125
     	return (in_array(request()->ip(), $skip_ip));
126 126
     }
127 127
 }
128 128
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,10 +63,14 @@
 block discarded – undo
63 63
 	 */
64 64
 	public function htmlScriptTagJsApi($formId = '')
65 65
 	{
66
-		if($this->skip_by_ip) return '';
66
+		if($this->skip_by_ip) {
67
+		    return '';
68
+		}
67 69
 		$html = "<script src='https://www.google.com/recaptcha/api.js' async defer></script>";
68 70
 		if($this->version != 'v2'){
69
-			if(!$formId) throw new Exception("formId required", 1);
71
+			if(!$formId) {
72
+			    throw new Exception("formId required", 1);
73
+			}
70 74
 			$html.= '<script>
71 75
 		       function biscolabLaravelReCaptcha(token) {
72 76
 		         document.getElementById("'.$formId.'").submit();
Please login to merge, or discard this patch.
config/recaptcha.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
 
14 14
 return [
15 15
 
16
-	/**
17
-	 *
18
-	 * The site key
19
-	 * get site key @ www.google.com/recaptcha/admin
20
-	 *
21
-	 */
16
+    /**
17
+     *
18
+     * The site key
19
+     * get site key @ www.google.com/recaptcha/admin
20
+     *
21
+     */
22 22
     'api_site_key'      => '',
23 23
 
24
-	/**
25
-	 *
26
-	 * The secret key
27
-	 * get secret key @ www.google.com/recaptcha/admin
28
-	 *
29
-	 */    
24
+    /**
25
+     *
26
+     * The secret key
27
+     * get secret key @ www.google.com/recaptcha/admin
28
+     *
29
+     */    
30 30
     'api_secret_key'    => '',
31 31
 
32 32
     /**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
      * get more info @ https://developers.google.com/recaptcha/docs/versions
38 38
      *
39 39
      */
40
-    'version'			=> 'v2'  ,
40
+    'version'			=> 'v2',
41 41
 
42 42
     /**
43 43
      *
Please login to merge, or discard this patch.