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

RevalidateJobSession   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 2
A removeSession() 0 4 1
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