SessionGuard::silentLogout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
crap 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