1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * Copyright (c) 2017 - present |
||||
5 | * LaravelGoogleRecaptcha - helpers.php |
||||
6 | * author: Roberto Belotti - [email protected] |
||||
7 | * web : robertobelotti.com, github.com/biscolab |
||||
8 | * Initial version created on: 12/9/2018 |
||||
9 | * MIT license: https://github.com/biscolab/laravel-recaptcha/blob/master/LICENSE |
||||
10 | */ |
||||
11 | |||||
12 | use Biscolab\ReCaptcha\Facades\ReCaptcha; |
||||
13 | |||||
14 | if (!function_exists('recaptcha')) { |
||||
15 | /** |
||||
16 | * @return Biscolab\ReCaptcha\ReCaptchaBuilder|\Biscolab\ReCaptcha\ReCaptchaBuilderV2|\Biscolab\ReCaptcha\ReCaptchaBuilderInvisible|\Biscolab\ReCaptcha\ReCaptchaBuilderV3 |
||||
17 | */ |
||||
18 | function recaptcha(): \Biscolab\ReCaptcha\ReCaptchaBuilder |
||||
19 | { |
||||
20 | |||||
21 | 14 | return app('recaptcha'); |
|||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
22 | } |
||||
23 | } |
||||
24 | |||||
25 | /** |
||||
26 | * call ReCaptcha::htmlScriptTagJsApi() |
||||
27 | * Write script HTML tag in you HTML code |
||||
28 | * Insert before </head> tag |
||||
29 | * |
||||
30 | * @param $config ['form_id'] required if you are using invisible ReCaptcha |
||||
31 | */ |
||||
32 | if (!function_exists('htmlScriptTagJsApi')) { |
||||
33 | |||||
34 | /** |
||||
35 | * @param array|null $config |
||||
36 | * |
||||
37 | * @return string |
||||
38 | */ |
||||
39 | function htmlScriptTagJsApi(?array $config = []): string |
||||
40 | { |
||||
41 | |||||
42 | 5 | return ReCaptcha::htmlScriptTagJsApi($config); |
|||
43 | } |
||||
44 | } |
||||
45 | |||||
46 | /** |
||||
47 | * call ReCaptcha::htmlFormButton() |
||||
48 | * Write HTML <button> tag in your HTML code |
||||
49 | * Insert before </form> tag |
||||
50 | * |
||||
51 | * Warning! Using only with ReCAPTCHA INVISIBLE |
||||
52 | * |
||||
53 | * @param $buttonInnerHTML What you want to write on the submit button |
||||
54 | */ |
||||
55 | if (!function_exists('htmlFormButton')) { |
||||
56 | |||||
57 | /** |
||||
58 | * @param null|string $button_label |
||||
59 | * @param array|null $properties |
||||
60 | * |
||||
61 | * @return string |
||||
62 | */ |
||||
63 | function htmlFormButton(?string $button_label = 'Submit', ?array $properties = []): string |
||||
64 | { |
||||
65 | |||||
66 | 2 | return ReCaptcha::htmlFormButton($button_label, $properties); |
|||
67 | } |
||||
68 | } |
||||
69 | |||||
70 | /** |
||||
71 | * call ReCaptcha::htmlFormSnippet() |
||||
72 | * Write ReCAPTCHA HTML tag in your FORM |
||||
73 | * Insert before </form> tag |
||||
74 | * |
||||
75 | * Warning! Using only with ReCAPTCHA v2 |
||||
76 | */ |
||||
77 | if (!function_exists('htmlFormSnippet')) { |
||||
78 | |||||
79 | /** |
||||
80 | * @param null|array $attributes |
||||
81 | * @return string |
||||
82 | */ |
||||
83 | function htmlFormSnippet(?array $attributes = []): string |
||||
84 | { |
||||
85 | |||||
86 | 2 | return ReCaptcha::htmlFormSnippet($attributes); |
|||
0 ignored issues
–
show
The call to
Biscolab\ReCaptcha\Facad...tcha::htmlFormSnippet() has too many arguments starting with $attributes .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.
Loading history...
|
|||||
87 | } |
||||
88 | } |
||||
89 | |||||
90 | /** |
||||
91 | * call ReCaptcha::getFormId() |
||||
92 | * return the form ID |
||||
93 | * Warning! Using only with ReCAPTCHA invisible |
||||
94 | */ |
||||
95 | if (!function_exists('getFormId')) { |
||||
96 | |||||
97 | /** |
||||
98 | * @return string |
||||
99 | */ |
||||
100 | function getFormId(): string |
||||
101 | { |
||||
102 | |||||
103 | 3 | return ReCaptcha::getFormId(); |
|||
104 | } |
||||
105 | } |
||||
106 | |||||
107 | /** |
||||
108 | * return ReCaptchaBuilder::DEFAULT_RECAPTCHA_RULE_NAME value ("recaptcha") |
||||
109 | * Use V2 (checkbox and invisible) |
||||
110 | */ |
||||
111 | if (!function_exists('recaptchaRuleName')) { |
||||
112 | |||||
113 | /** |
||||
114 | * @return string |
||||
115 | */ |
||||
116 | function recaptchaRuleName(): string |
||||
117 | { |
||||
118 | |||||
119 | 49 | return \Biscolab\ReCaptcha\ReCaptchaBuilder::DEFAULT_RECAPTCHA_RULE_NAME; |
|||
120 | } |
||||
121 | } |
||||
122 | |||||
123 | /** |
||||
124 | * return ReCaptchaBuilder::DEFAULT_RECAPTCHA_FIELD_NAME value "g-recaptcha-response" |
||||
125 | * Use V2 (checkbox and invisible) |
||||
126 | */ |
||||
127 | if (!function_exists('recaptchaFieldName')) { |
||||
128 | |||||
129 | /** |
||||
130 | * @return string |
||||
131 | */ |
||||
132 | function recaptchaFieldName(): string |
||||
133 | { |
||||
134 | |||||
135 | 1 | return \Biscolab\ReCaptcha\ReCaptchaBuilder::DEFAULT_RECAPTCHA_FIELD_NAME; |
|||
136 | } |
||||
137 | } |
||||
138 |