Skip to content

Commit 757551f

Browse files
committed
Use class constructor property promotion
1 parent 8871dea commit 757551f

File tree

1 file changed

+7
-34
lines changed

1 file changed

+7
-34
lines changed

src/Recaptcha.php

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,15 @@
88

99
class Recaptcha
1010
{
11-
/**
12-
* The http request instance.
13-
*/
14-
private Request $request;
15-
16-
/**
17-
* The recaptcha site key.
18-
*/
19-
private string $siteKey;
20-
21-
/**
22-
* The recaptcha secret key.
23-
*/
24-
private string $secretKey;
25-
26-
/**
27-
* The minimum score a recaptcha response must have to be valid.
28-
*/
29-
private float $minimumScore;
30-
31-
public function __construct(Request $request, string $siteKey, string $secretKey, float $minimumScore)
32-
{
33-
$this->request = $request;
34-
$this->siteKey = $siteKey;
35-
$this->secretKey = $secretKey;
36-
$this->minimumScore = $minimumScore;
11+
public function __construct(
12+
private Request $request,
13+
private string $siteKey,
14+
private string $secretKey,
15+
private float $minimumScore
16+
) {
3717
}
3818

39-
/**
40-
* Resolve the captcha score.
41-
*
42-
* @throws \GuzzleHttp\Exception\GuzzleException
43-
*/
19+
/** @throws \GuzzleHttp\Exception\GuzzleException */
4420
public function isValid(): bool
4521
{
4622
if (! $this->request->has('recaptcha_response')) {
@@ -68,9 +44,6 @@ public function isValid(): bool
6844
}
6945
}
7046

71-
/**
72-
* Get the required recaptcha js scripts.
73-
*/
7447
public function script(?string $action = null, string $elementId = 'recaptchaResponse'): string
7548
{
7649
return <<<EOD

0 commit comments

Comments
 (0)