Passed
Branch 001-basic (dcea18)
by Mr.
07:50
created

SessionUser   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromPayload() 0 13 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LibraryCatalog\ValueObject;
6
7
class SessionUser
8
{
9
    /** @var string */
10
    public string $roleId;
11
    /** @var string */
12
    public string $userId;
13
14
    /**
15
     * @param string $payload
16
     * @return SessionUser
17
     */
18 13
    public static function createFromPayload(string $payload): SessionUser
19
    {
20 13
        $res = new static();
21 13
        $ar = explode(':', $payload);
22 13
        if (is_array($ar)) {
0 ignored issues
show
introduced by
The condition is_array($ar) is always true.
Loading history...
23 13
            if (isset($ar[0])) {
24 13
                $res->roleId = (string)$ar[0];
25
            }
26 13
            if (isset($ar[1])) {
27 13
                $res->userId = (string)$ar[1];
28
            }
29
        }
30 13
        return $res;
31
    }
32
}
33