Skip to content

Commit f87eaee

Browse files
Recaptcha.php code style
1 parent 890406f commit f87eaee

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

src/Recaptcha.php

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,61 @@
22

33
namespace Greggilbert\Recaptcha;
44

5+
use Greggilbert\Recaptcha\Service\RecaptchaInterface;
6+
use Illuminate\View\View;
7+
58
class Recaptcha
69
{
7-
10+
/**
11+
* @var RecaptchaInterface
12+
*/
813
protected $service;
914

10-
protected $config = [ ];
15+
/**
16+
* @var array
17+
*/
18+
protected $config = [];
1119

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+
];
1331

1432

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+
) {
1741
$this->service = $service;
18-
$this->config = $config;
42+
$this->config = $config;
1943
}
2044

2145
/**
2246
* Render the recaptcha
2347
*
2448
* @param array $options
2549
*
26-
* @return view
50+
* @return View
2751
*/
28-
public function render($options = [ ])
29-
{
52+
public function render(
53+
array $options = []
54+
) {
3055
$mergedOptions = array_merge($this->config['options'], $options);
3156

3257
$data = [
3358
'public_key' => value($this->config['public_key']),
34-
'options' => $mergedOptions,
59+
'options' => $mergedOptions,
3560
'dataParams' => $this->extractDataParams($mergedOptions),
3661
];
3762

@@ -51,8 +76,9 @@ public function render($options = [ ])
5176
*
5277
* @return string
5378
*/
54-
protected function getView($options = [ ])
55-
{
79+
protected function getView(
80+
array $options = []
81+
): string {
5682
$view = 'recaptcha::' . $this->service->getTemplate();
5783

5884
$configTemplate = $this->config['template'];
@@ -74,8 +100,9 @@ protected function getView($options = [ ])
74100
*
75101
* @return array
76102
*/
77-
protected function extractDataParams($options = [ ])
78-
{
103+
protected function extractDataParams(
104+
array $options = []
105+
): array {
79106
return array_only($options, $this->dataParameterKeys);
80107
}
81108
}

0 commit comments

Comments
 (0)