CaptchaTrait::captchaCheck()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 8
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 13
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
    /**
11
     * Use Google ReCaptcha Service.
12
     *
13
     * @return bool ( description_of_the_return_value )
14
     */
15
    public function captchaCheck()
16
    {
17
        $response = Input::get('g-recaptcha-response');
18
        $remoteip = $_SERVER['REMOTE_ADDR'];
19
        $secret = config('blog.services.reCaptchSecret');
20
        $recaptcha = new ReCaptcha($secret);
21
        $resp = $recaptcha->verify($response, $remoteip);
22
23
        if ($resp->isSuccess()) {
24
            return true;
25
        }
26
27
        return false;
28
    }
29
}
30