CaptchaTrait::captchaCheck()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 8
c 1
b 1
f 0
nc 2
nop 0
dl 0
loc 14
rs 10
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