CaptchaTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A captchaCheck() 0 13 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
    /**
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