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

Commit

Permalink
Fix phpcs errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vencelkatai committed Feb 9, 2024
1 parent 1412366 commit fc2520a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
},
"require-dev": {
"orchestra/testbench": "5.*|6.*|^7.0|^8.0",
"phpunit/phpunit": "^9.1"
"phpunit/phpunit": "^9.1",
"squizlabs/php_codesniffer": "^3.0"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 9 additions & 9 deletions src/Controllers/ReCaptchaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
class ReCaptchaController extends Controller
{

/**
* @return array
*/
public function validateV3(): array
{
/**
* @return array
*/
public function validateV3(): array
{

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

return recaptcha()->validate($token);
}
}
return recaptcha()->validate($token);
}
}
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
class InvalidConfigurationException extends \Exception
{

}
}
1 change: 0 additions & 1 deletion src/ReCaptchaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ public function validate($response)
$url = $this->api_url . '?' . $params;

if (function_exists('curl_version')) {

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Expand Down
12 changes: 7 additions & 5 deletions src/ReCaptchaBuilderInvisible.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ public function htmlFormButton($button_label = 'Submit', ?array $properties = []

$tag_properties = '';

$properties = array_merge([
$properties = array_merge(
[
'data-callback' => 'biscolabLaravelReCaptcha',
], $properties,
[
],
$properties,
[
'data-sitekey' => $this->api_site_key
]);
]
);

if (empty($properties['class'])) {
$properties['class'] = 'g-recaptcha';
Expand Down Expand Up @@ -128,4 +131,3 @@ public function getFormId(): string
return $form_id;
}
}

24 changes: 19 additions & 5 deletions src/ReCaptchaBuilderV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(string $api_site_key, string $api_secret_key)
/**
* Write ReCAPTCHA HTML tag in your FORM
* Insert before </form> tag
*
*
* @param null|array $attributes
* @return string
*/
Expand Down Expand Up @@ -80,15 +80,27 @@ public function getTagAttributes(): array
$tag_attributes = array_merge($tag_attributes, config('recaptcha.tag_attributes', []));

if (Arr::get($tag_attributes, 'callback') === ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION) {
throw new InvalidConfigurationException('Property "callback" ("data-callback") must be different from "' . ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION . '"');
throw new InvalidConfigurationException(
'Property "callback" ("data-callback") must be different from "'
. ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION
. '"'
);
}

if (Arr::get($tag_attributes, 'expired-callback') === ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION) {
throw new InvalidConfigurationException('Property "expired-callback" ("data-expired-callback") must be different from "' . ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION . '"');
throw new InvalidConfigurationException(
'Property "expired-callback" ("data-expired-callback") must be different from "'
. ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION
. '"'
);
}

if (Arr::get($tag_attributes, 'error-callback') === ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION) {
throw new InvalidConfigurationException('Property "error-callback" ("data-error-callback") must be different from "' . ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION . '"');
throw new InvalidConfigurationException(
'Property "error-callback" ("data-error-callback") must be different from "'
. ReCaptchaBuilder::DEFAULT_ONLOAD_JS_FUNCTION
. '"'
);
}

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

$attributes = $this->getTagAttributes();

return "<script>var biscolabOnloadCallback = function() {grecaptcha.render('recaptcha-element', " . json_encode($attributes) . ");};</script>";
return "<script>var biscolabOnloadCallback = function() {grecaptcha.render('recaptcha-element', "
. json_encode($attributes)
. ");};</script>";
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/ReCaptchaBuilderV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ public function htmlScriptTagJsApi(?array $configuration = []): string

// Check if set custom_validation. That function will override default fetch validation function
if ($js_custom_validation) {

$validate_function = ($js_custom_validation) ? "{$js_custom_validation}(token);" : '';
} else {

$js_then_callback = Arr::get($configuration, 'callback_then', '');
$js_callback_catch = Arr::get($configuration, 'callback_catch', '');

Expand Down

0 comments on commit fc2520a

Please sign in to comment.