Completed
Push — master ( 544b6d...a5cf68 )
by Marceau
02:24
created

ProtectFromImpersonation::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
namespace Lab404\Impersonate\Middleware;
4
5
use Closure;
6
use Illuminate\Support\Facades\Redirect;
7
use Lab404\Impersonate\Services\ImpersonateManager;
8
9
class ProtectFromImpersonation
10
{
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param   \Illuminate\Http\Request  $request
15
     * @param   \Closure  $next
16
     * @return  mixed
17
     */
18
    public function handle($request, Closure $next)
19
    {
20
        $impersonate_manager = app()->make(ImpersonateManager::class);
21
22
        if ($impersonate_manager->isImpersonating()) {
23
            return Redirect::back();
24
        }
25
26
        return $next($request);
27
    }
28
}
29