1717 * Class ReCaptchaBuilder
1818 * @package Biscolab\ReCaptcha
1919 */
20- class ReCaptchaBuilder {
20+ class ReCaptchaBuilder
21+ {
2122
2223 /**
2324 * @var string
@@ -85,7 +86,8 @@ public function __construct(
8586 *
8687 * @return ReCaptchaBuilder
8788 */
88- public function setApiSiteKey (string $ api_site_key ): ReCaptchaBuilder {
89+ public function setApiSiteKey (string $ api_site_key ): ReCaptchaBuilder
90+ {
8991
9092 $ this ->api_site_key = $ api_site_key ;
9193
@@ -97,7 +99,8 @@ public function setApiSiteKey(string $api_site_key): ReCaptchaBuilder {
9799 *
98100 * @return ReCaptchaBuilder
99101 */
100- public function setApiSecretKey (string $ api_secret_key ): ReCaptchaBuilder {
102+ public function setApiSecretKey (string $ api_secret_key ): ReCaptchaBuilder
103+ {
101104
102105 $ this ->api_secret_key = $ api_secret_key ;
103106
@@ -107,7 +110,8 @@ public function setApiSecretKey(string $api_secret_key): ReCaptchaBuilder {
107110 /**
108111 * @return int
109112 */
110- public function getCurlTimeout (): int {
113+ public function getCurlTimeout (): int
114+ {
111115
112116 return config ('recaptcha.curl_timeout ' , self ::DEFAULT_CURL_TIMEOUT );
113117 }
@@ -117,7 +121,8 @@ public function getCurlTimeout(): int {
117121 *
118122 * @return ReCaptchaBuilder
119123 */
120- public function setVersion (string $ version ): ReCaptchaBuilder {
124+ public function setVersion (string $ version ): ReCaptchaBuilder
125+ {
121126
122127 $ this ->version = $ version ;
123128
@@ -127,7 +132,8 @@ public function setVersion(string $version): ReCaptchaBuilder {
127132 /**
128133 * @return string
129134 */
130- public function getVersion (): string {
135+ public function getVersion (): string
136+ {
131137
132138 return $ this ->version ;
133139 }
@@ -137,7 +143,8 @@ public function getVersion(): string {
137143 *
138144 * @return ReCaptchaBuilder
139145 */
140- public function setSkipByIp (bool $ skip_by_ip ): ReCaptchaBuilder {
146+ public function setSkipByIp (bool $ skip_by_ip ): ReCaptchaBuilder
147+ {
141148
142149 $ this ->skip_by_ip = $ skip_by_ip ;
143150
@@ -147,7 +154,8 @@ public function setSkipByIp(bool $skip_by_ip): ReCaptchaBuilder {
147154 /**
148155 * @return array|mixed
149156 */
150- public function getIpWhitelist () {
157+ public function getIpWhitelist ()
158+ {
151159
152160 $ whitelist = config ('recaptcha.skip_ip ' , []);
153161
@@ -163,7 +171,8 @@ public function getIpWhitelist() {
163171 *
164172 * @return boolean
165173 */
166- public function skipByIp (): bool {
174+ public function skipByIp (): bool
175+ {
167176
168177 return (in_array (request ()->ip (), $ this ->getIpWhitelist ()));
169178 }
@@ -178,7 +187,8 @@ public function skipByIp(): bool {
178187 * @return string
179188 * @throws Exception
180189 */
181- public function htmlScriptTagJsApi (?string $ formId = '' , ?array $ configuration = []): string {
190+ public function htmlScriptTagJsApi (?string $ formId = '' , ?array $ configuration = []): string
191+ {
182192
183193 if ($ this ->skip_by_ip ) {
184194 return '' ;
@@ -203,8 +213,7 @@ function biscolabLaravelReCaptcha(token) {
203213 document.getElementById(" ' . $ formId . '").submit();
204214 }
205215 </script> ' ;
206- }
207- elseif ($ this ->version == 'v3 ' ) {
216+ } elseif ($ this ->version == 'v3 ' ) {
208217
209218 $ action = Arr::get ($ configuration , 'action ' , 'homepage ' );
210219
@@ -214,8 +223,7 @@ function biscolabLaravelReCaptcha(token) {
214223 if ($ js_custom_validation ) {
215224
216225 $ validate_function = ($ js_custom_validation ) ? "{$ js_custom_validation }(token); " : '' ;
217- }
218- else {
226+ } else {
219227
220228 $ js_then_callback = Arr::get ($ configuration , 'callback_then ' , '' );
221229 $ js_callback_catch = Arr::get ($ configuration , 'callback_catch ' , '' );
@@ -258,7 +266,8 @@ function biscolabLaravelReCaptcha(token) {
258266 *
259267 * @return string
260268 */
261- public function htmlScriptTagJsApiV3 (?array $ configuration = []): string {
269+ public function htmlScriptTagJsApiV3 (?array $ configuration = []): string
270+ {
262271
263272 return $ this ->htmlScriptTagJsApi ('' , $ configuration );
264273 }
@@ -270,7 +279,8 @@ public function htmlScriptTagJsApiV3(?array $configuration = []): string {
270279 *
271280 * @return boolean|array
272281 */
273- public function validate ($ response ) {
282+ public function validate ($ response )
283+ {
274284
275285 if ($ this ->skip_by_ip ) {
276286 if ($ this ->returnArray ()) {
@@ -294,14 +304,14 @@ public function validate($response) {
294304 $ url = $ this ->api_url . '? ' . $ params ;
295305
296306 if (function_exists ('curl_version ' )) {
307+
297308 $ curl = curl_init ($ url );
298309 curl_setopt ($ curl , CURLOPT_HEADER , false );
299310 curl_setopt ($ curl , CURLOPT_RETURNTRANSFER , true );
300311 curl_setopt ($ curl , CURLOPT_TIMEOUT , $ this ->getCurlTimeout ());
301312 curl_setopt ($ curl , CURLOPT_SSL_VERIFYPEER , false );
302313 $ curl_response = curl_exec ($ curl );
303- }
304- else {
314+ } else {
305315 $ curl_response = file_get_contents ($ url );
306316 }
307317
@@ -348,7 +358,8 @@ public function getApiSecretKey(): string
348358 /**
349359 * @return bool
350360 */
351- protected function returnArray (): bool {
361+ protected function returnArray (): bool
362+ {
352363
353364 return ($ this ->version == 'v3 ' );
354365 }
0 commit comments