PlayerDto   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 43
ccs 0
cts 20
cp 0
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 8 1
A password() 0 3 1
A playerId() 0 3 1
A nickname() 0 3 1
A role() 0 3 1
A __construct() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Game\Features\Registration\Player;
6
7
use App\Game\Features\Registration\Role\Role;
8
use JsonSerializable;
9
10
/**
11
 * @psalm-immutable
12
 */
13
final class PlayerDto implements JsonSerializable
14
{
15
    private Role $role;
16
    private PlayerId $playerId;
17
    private string $password;
18
    private string $nickname;
19
20
    public function __construct(PlayerId $playerId, string $password, string $nickname, Role $role)
21
    {
22
        $this->playerId = $playerId;
23
        $this->role = $role;
24
        $this->nickname = $nickname;
25
        $this->password = $password;
26
    }
27
28
    public function playerId(): PlayerId
29
    {
30
        return $this->playerId;
31
    }
32
33
    public function role(): Role
34
    {
35
        return $this->role;
36
    }
37
38
    public function nickname(): string
39
    {
40
        return $this->nickname;
41
    }
42
43
    public function password(): string
44
    {
45
        return $this->password;
46
    }
47
48
    public function jsonSerialize(): array
49
    {
50
        return [
51
            'id' => (string) $this->playerId,
52
            'nickname' => $this->nickname,
53
            'password' => $this->password,
54
            'level' => 1,
55
            'role' => (string) $this->role->getValue(),
56
        ];
57
    }
58
}
59