CaptchaTrait::captchaCheck()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 8
c 2
b 1
f 0
nc 2
nop 0
dl 0
loc 14
rs 10
1
<?php
2
3
namespace App\Traits;
4
5
use Illuminate\Support\Facades\Input;
6
use ReCaptcha\ReCaptcha;
7
8
trait CaptchaTrait
9
{
10
    public function captchaCheck()
11
    {
12
        $response = Input::get('g-recaptcha-response');
13
        $remoteip = $_SERVER['REMOTE_ADDR'];
14
        $secret = env('RE_CAP_SECRET');
15
16
        $recaptcha = new ReCaptcha($secret);
17
        $resp = $recaptcha->verify($response, $remoteip);
18
19
        if ($resp->isSuccess()) {
20
            return true;
21
        }
22
23
        return false;
24
    }
25
}
26