Passed
Push — task/common-translation-packag... ( dbb970...52324d )
by Tristan
06:50 queued 11s
created

FinishHrRegistration::handle()   A

Complexity

Conditions 5
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 10
rs 9.6111
cc 5
nc 2
nop 2
1
<?php
2
namespace App\Http\Middleware;
3
4
use Closure;
5
6
class FinishHrRegistration
7
{
8
    /**
9
     * If logged in, but manager registration is incomplete, redirect to finish it.
10
     *
11
     * @param  \Illuminate\Http\Request  $request
12
     * @param  \Closure  $next
13
     * @return mixed
14
     */
15
    public function handle($request, Closure $next)
16
    {
17
        $user = $request->user();
18
19
        if ($user !== null && $user->isHrAdvisor()
20
            && ($user->gov_email === null || $user->hr_advisor->department_id === null)) {
21
            return redirect(route('hr_advisor.first_visit'));
0 ignored issues
show
Bug introduced by
The function route was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            return redirect(/** @scrutinizer ignore-call */ route('hr_advisor.first_visit'));
Loading history...
Bug introduced by
The function redirect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            return /** @scrutinizer ignore-call */ redirect(route('hr_advisor.first_visit'));
Loading history...
22
        }
23
24
        return $next($request);
25
    }
26
}
27