ActiveSession   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
1
<?php
2
3
namespace App\Security\Session;
4
5
use DateTimeImmutable;
6
7
class ActiveSession {
8
9
    public readonly array $browserInfo;
10
11
    public function __construct(public readonly int $userId, public readonly mixed $sessionId, public readonly ?string $userAgent,
12
                                public readonly DateTimeImmutable $startedAt, public readonly ?string $ipAddress, public readonly bool $isCurrentSession) {
13
        if($this->userAgent !== null) {
14
            $info = @get_browser($this->userAgent, true);
15
16
            if($info === false) {
17
                $this->browserInfo = [ ];
0 ignored issues
show
Bug introduced by
The property browserInfo is declared read-only in App\Security\Session\ActiveSession.
Loading history...
18
            } else {
19
                $this->browserInfo = $info;
20
            }
21
        } else {
22
            $this->browserInfo = [ ];
23
        }
24
    }
25
}