UserLoginLogMiddleware::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Moecasts\Laravel\UserLoginLog\Middleware;
4
5
use Closure;
6
use Illuminate\Support\Facades\Auth;
7
8
class UserLoginLogMiddleware
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @param  \Illuminate\Http\Request  $request
14
     * @param  \Closure  $next
15
     * @return mixed
16
     */
17 2
    public function handle($request, Closure $next)
18
    {
19 2
        if (Auth::check()) {
20 1
            $user = Auth::user();
21 1
            $user->logLogin();
0 ignored issues
show
Bug introduced by
The method logLogin() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User. ( Ignorable by Annotation )

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

21
            $user->/** @scrutinizer ignore-call */ 
22
                   logLogin();
Loading history...
22
        }
23 2
        return $next($request);
24
    }
25
}
26