Passed
Push — master ( 1894bb...f3ca15 )
by Vicens
03:07 queued 01:13
created

CaptchaMiddleware::getCaptcha()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Vicens\Captcha\Middleware;
4
5
use Closure;
6
use Illuminate\Support\Facades\Validator;
7
use Vicens\Captcha\Captcha;
8
use Illuminate\Http\Request;
9
10
class CaptchaMiddleware
11
{
12
13
    /**
14
     * @var Captcha
15
     */
16
    protected $captcha;
17
18
19
    public function __construct(Captcha $captcha)
20
    {
21
        $this->captcha = $captcha;
22
    }
23
24
    /**
25
     * @param Request $request
26
     * @param Closure $next
27
     * @return mixed
28
     * @throws \Illuminate\Validation\ValidationException
29
     */
30
    public function handle(Request $request, Closure $next)
31
    {
32
33
        Validator::validate($request->only('captcha'), [
34
            'captcha' => 'captcha'
35
        ]);
36
37
        return $next($request);
38
    }
39
}