Skip to content

Commit

Permalink
Use class constructor property promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
hedii committed Mar 5, 2022
1 parent 8871dea commit 757551f
Showing 1 changed file with 7 additions and 34 deletions.
41 changes: 7 additions & 34 deletions src/Recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,15 @@

class Recaptcha
{
/**
* The http request instance.
*/
private Request $request;

/**
* The recaptcha site key.
*/
private string $siteKey;

/**
* The recaptcha secret key.
*/
private string $secretKey;

/**
* The minimum score a recaptcha response must have to be valid.
*/
private float $minimumScore;

public function __construct(Request $request, string $siteKey, string $secretKey, float $minimumScore)
{
$this->request = $request;
$this->siteKey = $siteKey;
$this->secretKey = $secretKey;
$this->minimumScore = $minimumScore;
public function __construct(
private Request $request,
private string $siteKey,
private string $secretKey,
private float $minimumScore
) {
}

/**
* Resolve the captcha score.
*
* @throws \GuzzleHttp\Exception\GuzzleException
*/
/** @throws \GuzzleHttp\Exception\GuzzleException */
public function isValid(): bool
{
if (! $this->request->has('recaptcha_response')) {
Expand Down Expand Up @@ -68,9 +44,6 @@ public function isValid(): bool
}
}

/**
* Get the required recaptcha js scripts.
*/
public function script(?string $action = null, string $elementId = 'recaptchaResponse'): string
{
return <<<EOD
Expand Down

0 comments on commit 757551f

Please sign in to comment.