Completed
Branch job-vuejs (8df734)
by Adam
17:32
created

RevalidateJobSession::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Coyote\Http\Middleware;
4
5
use Closure;
6
use Coyote\Job;
7
use Illuminate\Http\Request;
8
9
class RevalidateJobSession
10
{
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param  Request  $request
15
     * @param  Closure  $next
16
     * @return mixed
17
     */
18
    public function handle(Request $request, Closure $next)
19
    {
20
        if ($request->has('revalidate')
21
//            || ($request->session()->has('job')
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
22
//                && $request->route('id') !== null
23
//                && $request->session()->get('job.id') !== $request->route('id'))
24
25
        ) {
26
            $this->removeSession($request);
27
        }
28
29
        return $next($request);
30
    }
31
32
    /**
33
     * @param Request  $request
34
     */
35
    private function removeSession(Request $request)
36
    {
37
        $request->session()->remove(Job::class);
38
    }
39
}
40