CaptchaTrait::captchaCheck()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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