SessionGuard   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A silentLogin() 0 5 1
A silentLogout() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\LaravelImpersonator\Guard;
6
7
use Illuminate\Auth\SessionGuard as BaseSessionGuard;
8
use Illuminate\Contracts\Auth\Authenticatable;
9
10
/**
11
 * Class     SessionGuard
12
 *
13
 * @author   ARCANEDEV <[email protected]>
14
 */
15
class SessionGuard extends BaseSessionGuard
16
{
17
    /* -----------------------------------------------------------------
18
     |  Main Methods
19
     | -----------------------------------------------------------------
20
     */
21
22
    /**
23
     * Login the user into the app without firing the Login event.
24
     *
25
     * @param  \Illuminate\Contracts\Auth\Authenticatable|mixed  $user
26
     */
27 32
    public function silentLogin(Authenticatable $user): void
28
    {
29 32
        $this->updateSession($user->getAuthIdentifier());
30 32
        $this->setUser($user);
31 32
    }
32
33
    /**
34
     * Logout the user without updating `remember_token` and without firing the Logout event.
35
     */
36 32
    public function silentLogout(): void
37
    {
38 32
        $this->clearUserDataFromStorage();
39
40 32
        $this->user      = null;
41 32
        $this->loggedOut = true;
42 32
    }
43
}
44