Passed
Push — develop ( ed5e20...ddaeab )
by Nikita
05:39
created

ReCaptcha   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 15 1
1
<?php
2
3
namespace Gameap\Validators;
4
5
use GuzzleHttp\Client;
6
7
class ReCaptcha
8
{
9
    public function validate($attribute, $value, $parameters, $validator)
0 ignored issues
show
Unused Code introduced by
The parameter $attribute is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

9
    public function validate(/** @scrutinizer ignore-unused */ $attribute, $value, $parameters, $validator)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $parameters is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

9
    public function validate($attribute, $value, /** @scrutinizer ignore-unused */ $parameters, $validator)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $validator is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

9
    public function validate($attribute, $value, $parameters, /** @scrutinizer ignore-unused */ $validator)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
10
    {
11
        $client = new Client();
12
13
        $response = $client->post('https://www.google.com/recaptcha/api/siteverify',
14
            ['form_params'=>
15
                [
16
                    'secret' => env('GOOGLE_RECAPTCHA_SECRET'),
17
                    'response' => $value
18
                ]
19
            ]
20
        );
21
22
        $body = json_decode((string)$response->getBody());
23
        return $body->success;
24
    }
25
}