DatabaseSessionHandler::addUserInformation()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.9666
cc 3
nc 3
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Overrides\Illuminate\Session;
6
7
use Illuminate\Contracts\Auth\Guard;
8
use Illuminate\Session\DatabaseSessionHandler as BaseDatabaseSessionHandler;
9
10
class DatabaseSessionHandler extends BaseDatabaseSessionHandler
11
{
12
    /**
13
     * Add the user information to the session payload.
14
     *
15
     * @param array $payload
16
     *
17
     * @return $this
18
     */
19
    protected function addUserInformation(&$payload)
20
    {
21
        if ($this->container->bound(Guard::class)) {
22
            $payload['user_id'] = $this->userId();
23
            $payload['user_type'] = ($user = $this->container->make(Guard::class)->user()) ? $user->getMorphClass() : null;
24
        }
25
26
        return $this;
27
    }
28
}
29