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

Commit 3e990f5

Browse files
committed
Merge branch 'release/v4'
* release/v4: Optimization and bug fix. Closes #27
2 parents c758067 + 75c5bcd commit 3e990f5

7 files changed

+34
-37
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Laravel ReCAPTCHA v3
1+
# Laravel ReCAPTCHA v3, checkbox and invisible
22
Simple and painless Google reCAPTCHA package for Laravel 5 and 6
33

44
Available reCAPTCHA versions:
@@ -14,7 +14,7 @@ Available reCAPTCHA versions:
1414
| Package | reCAPTCHA | PHP | Laravel | Docs |
1515
|-----------------|-------------|-------------|-----------------|-------------------|
1616
| 4.x |v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6 | [latest](https://laravel-recaptcha-docs.biscolab.com) |
17-
| 3.x |v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6 ready (*) | [latest](https://laravel-recaptcha-docs.biscolab.com/docs/3.6.1/intro) |
17+
| 3.x |v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6 ready (*) | [v3.6.1](https://laravel-recaptcha-docs.biscolab.com/docs/3.6.1/intro) |
1818
| 2.x | v2 Invisible, v2 Checkbox | 5.5.9, 7.0 or greater | 5.0 or greater | [v2.0.4](https://laravel-recaptcha-docs.biscolab.com/docs/2.0.4/intro) |
1919

2020
> (*) Latest version (3.6.1) is Laravel 6 ready

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "biscolab/laravel-recaptcha",
33
"description": "Simple ReCaptcha package for Laravel 5 and 6",
4-
"version": "4.0.0",
4+
"version": "4.0.1",
55
"license": "MIT",
66
"type": "library",
77
"keywords": [

src/Facades/ReCaptcha.php

+14-9
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@
1515
/**
1616
* Class ReCaptcha
1717
* @package Biscolab\ReCaptcha\Facades
18+
*
19+
* @method static string htmlScriptTagJsApi(?array $config = [])
20+
* @method static string htmlFormButton(?string $button_label = '', ?array $properties = [])
21+
* @method static string htmlFormSnippet()
22+
* @method static string getFormId()
1823
*/
1924
class ReCaptcha extends Facade
2025
{
2126

22-
/**
23-
* Get the registered name of the component.
24-
*
25-
* @return string
26-
*/
27-
protected static function getFacadeAccessor()
28-
{
27+
/**
28+
* Get the registered name of the component.
29+
*
30+
* @return string
31+
*/
32+
protected static function getFacadeAccessor()
33+
{
2934

30-
return 'recaptcha';
31-
}
35+
return 'recaptcha';
36+
}
3237
}

src/ReCaptchaBuilder.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function htmlScriptTagJsApi(?array $configuration = []): string
213213

214214
// Language: "hl" parameter
215215
// resources $configuration parameter overrides default language
216-
$language = Arr::get($configuration, 'resources');
216+
$language = Arr::get($configuration, 'lang');
217217
if (!$language) {
218218
$language = config('recaptcha.default_language', null);
219219
}
@@ -227,6 +227,7 @@ public function htmlScriptTagJsApi(?array $configuration = []): string
227227
Arr::set($query, 'render', 'explicit');
228228
Arr::set($query, 'onload', self::DEFAULT_ONLOAD_JS_FUNCTION);
229229

230+
/** @scrutinizer ignore-call */
230231
$html = $this->getOnLoadCallback();
231232
}
232233

src/helpers.php

-21
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,6 @@ function htmlScriptTagJsApi(?array $config = []): string
4242
}
4343
}
4444

45-
/**
46-
* call ReCaptcha::htmlScriptTagJsApi()
47-
* Write script HTML tag in you HTML code
48-
* Insert before </head> tag
49-
*
50-
*/
51-
if (!function_exists('htmlScriptTagJsApiV3')) {
52-
53-
/**
54-
* @param array $config
55-
*
56-
* @return string
57-
* @deprecated
58-
*/
59-
function htmlScriptTagJsApiV3(?array $config = []): string
60-
{
61-
62-
return ReCaptcha::htmlScriptTagJsApiV3($config);
63-
}
64-
}
65-
6645
/**
6746
* call ReCaptcha::htmlFormButton()
6847
* Write HTML <button> tag in your HTML code

tests/ReCaptchaHelpersV2ExplicitTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ public function testGetOnLoadCallbackFunction()
2222
{
2323

2424
$recaptcha = \recaptcha();
25-
25+
/** @scrutinizer ignore-call */
2626
$callback = $recaptcha->getOnLoadCallback();
2727

28-
$this->assertEquals('<script>var biscolabOnloadCallback = function() {grecaptcha.render(\'recaptcha-element\', {"sitekey":"api_site_key","theme":"dark","size":"compact","tabindex":"2","callback":"callbackFunction","expired-callback":"expiredCallbackFunction","error-callback":"errorCallbackFunction"});};</script>', $callback);
28+
$this->assertEquals('<script>var biscolabOnloadCallback = function() {grecaptcha.render(\'recaptcha-element\', {"sitekey":"api_site_key","theme":"dark","size":"compact","tabindex":"2","callback":"callbackFunction","expired-callback":"expiredCallbackFunction","error-callback":"errorCallbackFunction"});};</script>',
29+
$callback);
2930
}
3031

3132
/**
@@ -47,7 +48,7 @@ public function testTagAttributes()
4748
{
4849

4950
$recaptcha = \recaptcha();
50-
51+
/** @scrutinizer ignore-call */
5152
$tag_attributes = $recaptcha->getTagAttributes();
5253

5354
$this->assertArrayHasKey('sitekey', $tag_attributes);
@@ -82,6 +83,7 @@ public function testExpectReCaptchaInstanceOfReCaptchaBuilderV2()
8283
public function testHtmlFormSnippet()
8384
{
8485

86+
/** @scrutinizer ignore-call */
8587
$html_snippet = \recaptcha()->htmlFormSnippet();
8688
$this->assertEquals('<div class="g-recaptcha" data-sitekey="api_site_key" data-theme="dark" data-size="compact" data-tabindex="2" data-callback="callbackFunction" data-expired-callback="expiredCallbackFunction" data-error-callback="errorCallbackFunction" id="recaptcha-element"></div>',
8789
$html_snippet);

tests/ReCaptchaLangTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public function testHtmlScriptTagJsApiGetHtmlScriptWithHlParam()
3737
$this->assertEquals('<script src="https://www.google.com/recaptcha/api.js?hl=it" async defer></script>', $r);
3838
}
3939

40+
/**
41+
* @tests
42+
*/
43+
public function testHtmlScriptTagJsApiGetHtmlScriptOverridingHlParam()
44+
{
45+
46+
$r = ReCaptcha::htmlScriptTagJsApi(['lang' => 'en']);
47+
$this->assertEquals('<script src="https://www.google.com/recaptcha/api.js?hl=en" async defer></script>', $r);
48+
}
49+
4050
/**
4151
* Define environment setup.
4252
*

0 commit comments

Comments
 (0)