2
2
3
3
namespace Greggilbert \Recaptcha ;
4
4
5
+ use Greggilbert \Recaptcha \Service \RecaptchaInterface ;
6
+ use Illuminate \View \View ;
7
+
5
8
class Recaptcha
6
9
{
7
-
10
+ /**
11
+ * @var RecaptchaInterface
12
+ */
8
13
protected $ service ;
9
14
10
- protected $ config = [ ];
15
+ /**
16
+ * @var array
17
+ */
18
+ protected $ config = [];
11
19
12
- protected $ dataParameterKeys = [ 'theme ' , 'type ' , 'callback ' , 'tabindex ' , 'expired-callback ' , 'badge ' ];
20
+ /**
21
+ * @var array
22
+ */
23
+ protected $ dataParameterKeys = [
24
+ 'theme ' ,
25
+ 'type ' ,
26
+ 'callback ' ,
27
+ 'tabindex ' ,
28
+ 'expired-callback ' ,
29
+ 'badge ' ,
30
+ ];
13
31
14
32
15
- public function __construct ($ service , $ config )
16
- {
33
+ /**
34
+ * @param $service
35
+ * @param $config
36
+ */
37
+ public function __construct (
38
+ RecaptchaInterface $ service ,
39
+ array $ config
40
+ ) {
17
41
$ this ->service = $ service ;
18
- $ this ->config = $ config ;
42
+ $ this ->config = $ config ;
19
43
}
20
44
21
45
/**
22
46
* Render the recaptcha
23
47
*
24
48
* @param array $options
25
49
*
26
- * @return view
50
+ * @return View
27
51
*/
28
- public function render ($ options = [ ])
29
- {
52
+ public function render (
53
+ array $ options = []
54
+ ) {
30
55
$ mergedOptions = array_merge ($ this ->config ['options ' ], $ options );
31
56
32
57
$ data = [
33
58
'public_key ' => value ($ this ->config ['public_key ' ]),
34
- 'options ' => $ mergedOptions ,
59
+ 'options ' => $ mergedOptions ,
35
60
'dataParams ' => $ this ->extractDataParams ($ mergedOptions ),
36
61
];
37
62
@@ -51,8 +76,9 @@ public function render($options = [ ])
51
76
*
52
77
* @return string
53
78
*/
54
- protected function getView ($ options = [ ])
55
- {
79
+ protected function getView (
80
+ array $ options = []
81
+ ): string {
56
82
$ view = 'recaptcha:: ' . $ this ->service ->getTemplate ();
57
83
58
84
$ configTemplate = $ this ->config ['template ' ];
@@ -74,8 +100,9 @@ protected function getView($options = [ ])
74
100
*
75
101
* @return array
76
102
*/
77
- protected function extractDataParams ($ options = [ ])
78
- {
103
+ protected function extractDataParams (
104
+ array $ options = []
105
+ ): array {
79
106
return array_only ($ options , $ this ->dataParameterKeys );
80
107
}
81
108
}
0 commit comments