Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit fc2520a

Browse files
committed
Fix phpcs errors
1 parent 1412366 commit fc2520a

7 files changed

+38
-24
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},
2626
"require-dev": {
2727
"orchestra/testbench": "5.*|6.*|^7.0|^8.0",
28-
"phpunit/phpunit": "^9.1"
28+
"phpunit/phpunit": "^9.1",
29+
"squizlabs/php_codesniffer": "^3.0"
2930
},
3031
"autoload": {
3132
"psr-4": {

src/Controllers/ReCaptchaController.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
class ReCaptchaController extends Controller
2020
{
2121

22-
/**
23-
* @return array
24-
*/
25-
public function validateV3(): array
26-
{
22+
/**
23+
* @return array
24+
*/
25+
public function validateV3(): array
26+
{
2727

28-
$token = request()->input(config('recaptcha.default_token_parameter_name', 'token'), '');
28+
$token = request()->input(config('recaptcha.default_token_parameter_name', 'token'), '');
2929

30-
return recaptcha()->validate($token);
31-
}
32-
}
30+
return recaptcha()->validate($token);
31+
}
32+
}

src/Exceptions/InvalidConfigurationException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
class InvalidConfigurationException extends \Exception
1414
{
1515

16-
}
16+
}

src/ReCaptchaBuilder.php

-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ public function validate($response)
325325
$url = $this->api_url . '?' . $params;
326326

327327
if (function_exists('curl_version')) {
328-
329328
$curl = curl_init($url);
330329
curl_setopt($curl, CURLOPT_HEADER, false);
331330
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

src/ReCaptchaBuilderInvisible.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ public function htmlFormButton($button_label = 'Submit', ?array $properties = []
5151

5252
$tag_properties = '';
5353

54-
$properties = array_merge([
54+
$properties = array_merge(
55+
[
5556
'data-callback' => 'biscolabLaravelReCaptcha',
56-
], $properties,
57-
[
57+
],
58+
$properties,
59+
[
5860
'data-sitekey' => $this->api_site_key
59-
]);
61+
]
62+
);
6063

6164
if (empty($properties['class'])) {
6265
$properties['class'] = 'g-recaptcha';
@@ -128,4 +131,3 @@ public function getFormId(): string
128131
return $form_id;
129132
}
130133
}
131-

src/ReCaptchaBuilderV2.php

+19-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(string $api_site_key, string $api_secret_key)
4545
/**
4646
* Write ReCAPTCHA HTML tag in your FORM
4747
* Insert before </form> tag
48-
*
48+
*
4949
* @param null|array $attributes
5050
* @return string
5151
*/
@@ -80,15 +80,27 @@ public function getTagAttributes(): array
8080
$tag_attributes = array_merge($tag_attributes, config('recaptcha.tag_attributes', []));
8181

8282
if (Arr::get($tag_attributes, 'callback') === ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION) {
83-
throw new InvalidConfigurationException('Property "callback" ("data-callback") must be different from "' . ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION . '"');
83+
throw new InvalidConfigurationException(
84+
'Property "callback" ("data-callback") must be different from "'
85+
. ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION
86+
. '"'
87+
);
8488
}
8589

8690
if (Arr::get($tag_attributes, 'expired-callback') === ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION) {
87-
throw new InvalidConfigurationException('Property "expired-callback" ("data-expired-callback") must be different from "' . ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION . '"');
91+
throw new InvalidConfigurationException(
92+
'Property "expired-callback" ("data-expired-callback") must be different from "'
93+
. ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION
94+
. '"'
95+
);
8896
}
8997

9098
if (Arr::get($tag_attributes, 'error-callback') === ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION) {
91-
throw new InvalidConfigurationException('Property "error-callback" ("data-error-callback") must be different from "' . ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION . '"');
99+
throw new InvalidConfigurationException(
100+
'Property "error-callback" ("data-error-callback") must be different from "'
101+
. ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION
102+
. '"'
103+
);
92104
}
93105

94106
return $tag_attributes;
@@ -102,7 +114,9 @@ public function getOnLoadCallback(): string
102114

103115
$attributes = $this->getTagAttributes();
104116

105-
return "<script>var biscolabOnloadCallback = function() {grecaptcha.render('recaptcha-element', " . json_encode($attributes) . ");};</script>";
117+
return "<script>var biscolabOnloadCallback = function() {grecaptcha.render('recaptcha-element', "
118+
. json_encode($attributes)
119+
. ");};</script>";
106120
}
107121

108122
/**

src/ReCaptchaBuilderV3.php

-2
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,8 @@ public function htmlScriptTagJsApi(?array $configuration = []): string
8282

8383
// Check if set custom_validation. That function will override default fetch validation function
8484
if ($js_custom_validation) {
85-
8685
$validate_function = ($js_custom_validation) ? "{$js_custom_validation}(token);" : '';
8786
} else {
88-
8987
$js_then_callback = Arr::get($configuration, 'callback_then', '');
9088
$js_callback_catch = Arr::get($configuration, 'callback_catch', '');
9189

0 commit comments

Comments
 (0)