GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ReCaptcha::isValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\API\Value\Captcha;
6
7
use Netgen\InformationCollection\API\Service\CaptchaValue;
8
use ReCaptcha\ReCaptcha as BaseReCaptcha;
9
use Symfony\Component\HttpFoundation\Request;
10
11
class ReCaptcha implements CaptchaValue
12
{
13
    /**
14
     * @var \ReCaptcha\ReCaptcha
15
     */
16
    protected $reCaptcha;
17
18
    /**
19
     * ReCaptcha constructor.
20
     *
21
     * @param \ReCaptcha\ReCaptcha $reCaptcha
22
     */
23
    public function __construct(BaseReCaptcha $reCaptcha)
24
    {
25
        $this->reCaptcha = $reCaptcha;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function isValid(Request $request): bool
32
    {
33
        $response = $this->reCaptcha->verify(
34
            $request->request->get('g-recaptcha-response'),
35
            $request->getClientIp()
36
        );
37
38
        return $response->isSuccess();
39
    }
40
41
    /**
42
     * Returns aggregated captcha implementation.
43
     *
44
     * @return \ReCaptcha\ReCaptcha
45
     */
46
    public function getInnerCaptcha(): BaseReCaptcha
47
    {
48
        return $this->reCaptcha;
49
    }
50
}
51