Captcha::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Torralbodavid\SimpleRecaptchaV3\Services;
4
5
class Captcha
6
{
7
    protected const SERVICE_URL = 'https://www.google.com/recaptcha/api/siteverify';
8
    protected $secret;
9
    protected $response;
10
11
    public function __invoke($recaptcha_response)
12
    {
13
        $this->secret = config('simple-recaptcha-v3.secret_key');
14
        $this->response = $recaptcha_response;
15
16
        $recaptcha = file_get_contents(self::SERVICE_URL.'?secret='.$this->secret.'&response='.$this->response);
17
18
        return json_decode($recaptcha);
19
    }
20
}
21