Completed
Push — develop ( 1c3d8e...dc7d05 )
by Mohamed
07:44
created

VerifyAjaxRequest::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 2.0625
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Http\Middleware;
13
14
use Closure;
15
use Illuminate\Http\Request;
16
17
/**
18
 * VerifyAjaxRequest is a Middleware class to limit request to Ajax call only.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 */
22
class VerifyAjaxRequest
23
{
24
    /**
25
     * Handle an incoming request.
26
     *
27
     * @param Request $request
28
     * @param Closure $next
29
     *
30
     * @return mixed
31
     */
32 19
    public function handle(Request $request, Closure $next)
33
    {
34 19
        if (!$request->ajax()) {
35
            return response('Not found', 404);
36
        }
37
38 19
        return $next($request);
39
    }
40
}
41