CaptchaTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 9
c 2
b 1
f 0
dl 0
loc 16
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A captchaCheck() 0 14 2
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