CaptchaTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
eloc 9
c 2
b 2
f 0
dl 0
loc 21
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 ReCaptcha\ReCaptcha;
6
use Request;
7
8
trait CaptchaTrait
9
{
10
    /**
11
     * Check Google Captcha Passed or Failed.
12
     *
13
     * @return bool
14
     */
15
    public function captchaCheck()
16
    {
17
        $response = Request::get('g-recaptcha-response');
18
        $remoteip = $_SERVER['REMOTE_ADDR'];
19
        $secret = config('settings.reCaptchSecret');
20
21
        $recaptcha = new ReCaptcha($secret);
22
        $resp = $recaptcha->verify($response, $remoteip);
23
24
        if ($resp->isSuccess()) {
25
            return true;
26
        }
27
28
        return false;
29
    }
30
}
31