Completed
Push — develop ( 335c93...e4583a )
by Mohamed
12:58
created

VerifyAjaxRequest::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 2
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 12
    public function handle(Request $request, Closure $next)
33
    {
34 12
        if (!$request->ajax()) {
35 1
            return response('Not found', 404);
36
        }
37
38 11
        return $next($request);
39
    }
40
}
41