diff --git a/composer.json b/composer.json index 377be58..8c0cdfb 100755 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/src/Controllers/ReCaptchaController.php b/src/Controllers/ReCaptchaController.php index 736f0f7..c07afef 100644 --- a/src/Controllers/ReCaptchaController.php +++ b/src/Controllers/ReCaptchaController.php @@ -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); - } -} \ No newline at end of file + return recaptcha()->validate($token); + } +} diff --git a/src/Exceptions/InvalidConfigurationException.php b/src/Exceptions/InvalidConfigurationException.php index a582ce4..2e2a5a1 100644 --- a/src/Exceptions/InvalidConfigurationException.php +++ b/src/Exceptions/InvalidConfigurationException.php @@ -13,4 +13,4 @@ class InvalidConfigurationException extends \Exception { -} \ No newline at end of file +} diff --git a/src/ReCaptchaBuilder.php b/src/ReCaptchaBuilder.php index c97652c..05af474 100755 --- a/src/ReCaptchaBuilder.php +++ b/src/ReCaptchaBuilder.php @@ -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); diff --git a/src/ReCaptchaBuilderInvisible.php b/src/ReCaptchaBuilderInvisible.php index 26a7974..93ffaa6 100644 --- a/src/ReCaptchaBuilderInvisible.php +++ b/src/ReCaptchaBuilderInvisible.php @@ -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'; @@ -128,4 +131,3 @@ public function getFormId(): string return $form_id; } } - diff --git a/src/ReCaptchaBuilderV2.php b/src/ReCaptchaBuilderV2.php index ca0de81..82f1f81 100644 --- a/src/ReCaptchaBuilderV2.php +++ b/src/ReCaptchaBuilderV2.php @@ -45,7 +45,7 @@ public function __construct(string $api_site_key, string $api_secret_key) /** * Write ReCAPTCHA HTML tag in your FORM * Insert before tag - * + * * @param null|array $attributes * @return string */ @@ -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; @@ -102,7 +114,9 @@ public function getOnLoadCallback(): string $attributes = $this->getTagAttributes(); - return ""; + return ""; } /** diff --git a/src/ReCaptchaBuilderV3.php b/src/ReCaptchaBuilderV3.php index d57aef6..73af60e 100644 --- a/src/ReCaptchaBuilderV3.php +++ b/src/ReCaptchaBuilderV3.php @@ -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', '');