1 | <?php |
||||
2 | /** |
||||
3 | * Copyright (c) 2017 - present |
||||
4 | * LaravelGoogleRecaptcha - helpers.php |
||||
5 | * author: Roberto Belotti - [email protected] |
||||
6 | * web : robertobelotti.com, github.com/biscolab |
||||
7 | * Initial version created on: 12/9/2018 |
||||
8 | * MIT license: https://github.com/biscolab/laravel-recaptcha/blob/master/LICENSE |
||||
9 | */ |
||||
10 | |||||
11 | use Biscolab\ReCaptcha\Facades\ReCaptcha; |
||||
12 | |||||
13 | if (!function_exists('recaptcha')) { |
||||
14 | /** |
||||
15 | * @return Biscolab\ReCaptcha\ReCaptchaBuilder|\Biscolab\ReCaptcha\ReCaptchaBuilderV2|\Biscolab\ReCaptcha\ReCaptchaBuilderInvisible|\Biscolab\ReCaptcha\ReCaptchaBuilderV3 |
||||
16 | */ |
||||
17 | function recaptcha(): \Biscolab\ReCaptcha\ReCaptchaBuilder |
||||
18 | { |
||||
19 | |||||
20 | 12 | return app('recaptcha'); |
|||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
21 | } |
||||
22 | } |
||||
23 | |||||
24 | /** |
||||
25 | * call ReCaptcha::htmlScriptTagJsApi() |
||||
26 | * Write script HTML tag in you HTML code |
||||
27 | * Insert before </head> tag |
||||
28 | * |
||||
29 | * @param $config ['form_id'] required if you are using invisible ReCaptcha |
||||
30 | */ |
||||
31 | if (!function_exists('htmlScriptTagJsApi')) { |
||||
32 | |||||
33 | /** |
||||
34 | * @param array|null $config |
||||
35 | * |
||||
36 | * @return string |
||||
37 | */ |
||||
38 | function htmlScriptTagJsApi(?array $config = []): string |
||||
39 | { |
||||
40 | |||||
41 | 5 | return ReCaptcha::htmlScriptTagJsApi($config); |
|||
42 | } |
||||
43 | } |
||||
44 | |||||
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 | |||||
66 | /** |
||||
67 | * call ReCaptcha::htmlFormButton() |
||||
68 | * Write HTML <button> tag in your HTML code |
||||
69 | * Insert before </form> tag |
||||
70 | * |
||||
71 | * Warning! Using only with ReCAPTCHA INVISIBLE |
||||
72 | * |
||||
73 | * @param $buttonInnerHTML What you want to write on the submit button |
||||
74 | */ |
||||
75 | if (!function_exists('htmlFormButton')) { |
||||
76 | |||||
77 | /** |
||||
78 | * @param null|string $button_label |
||||
79 | * @param array|null $properties |
||||
80 | * |
||||
81 | * @return string |
||||
82 | */ |
||||
83 | function htmlFormButton(?string $button_label = 'Submit', ?array $properties = []): string |
||||
84 | { |
||||
85 | |||||
86 | 2 | return ReCaptcha::htmlFormButton($button_label, $properties); |
|||
0 ignored issues
–
show
The method
htmlFormButton() does not exist on Biscolab\ReCaptcha\Facades\ReCaptcha . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
87 | } |
||||
88 | } |
||||
89 | |||||
90 | /** |
||||
91 | * call ReCaptcha::htmlFormSnippet() |
||||
92 | * Write ReCAPTCHA HTML tag in your FORM |
||||
93 | * Insert before </form> tag |
||||
94 | * |
||||
95 | * Warning! Using only with ReCAPTCHA v2 |
||||
96 | */ |
||||
97 | if (!function_exists('htmlFormSnippet')) { |
||||
98 | |||||
99 | /** |
||||
100 | * @return string |
||||
101 | */ |
||||
102 | function htmlFormSnippet(): string |
||||
103 | { |
||||
104 | |||||
105 | 2 | return ReCaptcha::htmlFormSnippet(); |
|||
106 | } |
||||
107 | } |
||||
108 | |||||
109 | /** |
||||
110 | * call ReCaptcha::getFormId() |
||||
111 | * return the form ID |
||||
112 | * Warning! Using only with ReCAPTCHA invisible |
||||
113 | */ |
||||
114 | if (!function_exists('getFormId')) { |
||||
115 | |||||
116 | /** |
||||
117 | * @return string |
||||
118 | */ |
||||
119 | function getFormId(): string |
||||
120 | { |
||||
121 | |||||
122 | 3 | return ReCaptcha::getFormId(); |
|||
0 ignored issues
–
show
The method
getFormId() does not exist on Biscolab\ReCaptcha\Facades\ReCaptcha . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
123 | } |
||||
124 | } |
||||
125 | |||||
126 | /** |
||||
127 | * return ReCaptchaBuilder::DEFAULT_RECAPTCHA_RULE_NAME value ("recaptcha") |
||||
128 | * Use V2 (checkbox and invisible) |
||||
129 | */ |
||||
130 | if (!function_exists('recaptchaRuleName')) { |
||||
131 | |||||
132 | /** |
||||
133 | * @return string |
||||
134 | */ |
||||
135 | function recaptchaRuleName(): string |
||||
136 | { |
||||
137 | |||||
138 | 42 | return \Biscolab\ReCaptcha\ReCaptchaBuilder::DEFAULT_RECAPTCHA_RULE_NAME; |
|||
139 | } |
||||
140 | } |
||||
141 | |||||
142 | /** |
||||
143 | * return ReCaptchaBuilder::DEFAULT_RECAPTCHA_FIELD_NAME value "g-recaptcha-response" |
||||
144 | * Use V2 (checkbox and invisible) |
||||
145 | */ |
||||
146 | if (!function_exists('recaptchaFieldName')) { |
||||
147 | |||||
148 | /** |
||||
149 | * @return string |
||||
150 | */ |
||||
151 | function recaptchaFieldName(): string |
||||
152 | { |
||||
153 | |||||
154 | 1 | return \Biscolab\ReCaptcha\ReCaptchaBuilder::DEFAULT_RECAPTCHA_FIELD_NAME; |
|||
155 | } |
||||
156 | } |
||||
157 | |||||
158 |