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

ProtectFromImpersonation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 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