Passed
Push — master ( ac7ac5...67fb51 )
by Roberto
03:29
created

src/helpers.php (2 issues)

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
16
	 */
17
	function recaptcha() {
18
19
		return app('recaptcha');
1 ignored issue
show
Bug Best Practice introduced by
The expression return app('recaptcha') also could return the type Illuminate\Foundation\Application which is incompatible with the documented return type Biscolab\ReCaptcha\ReCaptchaBuilder.
Loading history...
20
	}
21
}
22
23
/**
24
 * call ReCaptcha::htmlScriptTagJsApi()
25
 * Write script HTML tag in you HTML code
26
 * Insert before </head> tag
27
 *
28
 * @param $formId required if you are using invisible ReCaptcha
29
 */
30
if (!function_exists('htmlScriptTagJsApi')) {
31
32
	/**
33
	 * @param string $formId
34
	 *
35
	 * @return string
36
	 */
37
	function htmlScriptTagJsApi($formId = ''): string {
38
39
		return ReCaptcha::htmlScriptTagJsApi($formId);
40
	}
41
}
42
43
/**
44
 * call ReCaptcha::htmlScriptTagJsApi()
45
 * Write script HTML tag in you HTML code
46
 * Insert before </head> tag
47
 *
48
 * @param $formId required if you are using invisible ReCaptcha
49
 */
50
if (!function_exists('htmlScriptTagJsApiV3')) {
51
52
	/**
53
	 * @param array $config
54
	 *
55
	 * @return string
56
	 */
57
	function htmlScriptTagJsApiV3($config = []): string {
58
59
		return ReCaptcha::htmlScriptTagJsApiV3($config);
1 ignored issue
show
The method htmlScriptTagJsApiV3() 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 ignore-call  annotation

59
		return ReCaptcha::/** @scrutinizer ignore-call */ htmlScriptTagJsApiV3($config);
Loading history...
60
	}
61
}
62
63
/**
64
 * call ReCaptcha::htmlFormButton()
65
 * Write HTML <button> tag in your HTML code
66
 * Insert before </form> tag
67
 *
68
 * Warning! Using only with ReCAPTCHA INVISIBLE
69
 *
70
 * @param $buttonInnerHTML What you want to write on the submit button
71
 */
72
if (!function_exists('htmlFormButton')) {
73
74
	/**
75
	 * @param null|string $buttonInnerHTML
76
	 *
77
	 * @return string
78
	 */
79
	function htmlFormButton(?string $buttonInnerHTML = 'Submit'): string {
80
81
		return ReCaptcha::htmlFormButton($buttonInnerHTML);
82
	}
83
}
84
85
/**
86
 * call ReCaptcha::htmlFormSnippet()
87
 * Write ReCAPTCHA HTML tag in your FORM
88
 * Insert before </form> tag
89
 *
90
 * Warning! Using only with ReCAPTCHA v2
91
 */
92
if (!function_exists('htmlFormSnippet')) {
93
94
	/**
95
	 * @return string
96
	 */
97
	function htmlFormSnippet(): string {
98
99
		return ReCaptcha::htmlFormSnippet();
100
	}
101
}
102
103