Passed
Push — master ( df80bc...5cc7cd )
by Jérémy
03:15 queued 01:22
created

CurrentUserDto   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 41
c 1
b 0
f 0
dl 0
loc 103
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A id() 0 3 1
A settings() 0 3 1
A name() 0 3 1
A email() 0 3 1
A profilePicture() 0 3 1
A __construct() 0 20 1
A status() 0 3 1
A activeWorkspace() 0 3 1
A defaultWorkspace() 0 3 1
A memberships() 0 3 1
A fromArray() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JDecool\Clockify\Model;
6
7
class CurrentUserDto
8
{
9
    private $activeWorkspace;
10
    private $defaultWorkspace;
11
    private $email;
12
    private $id;
13
    private $memberships;
14
    private $name;
15
    private $profilePicture;
16
    private $settings;
17
    private $status;
18
19
    public static function fromArray(array $data): self
20
    {
21
        return new self(
22
            $data['activeWorkspace'],
23
            $data['defaultWorkspace'],
24
            $data['email'],
25
            $data['id'],
26
            array_map(
27
                static function(array $membership): MembershipDto {
28
                    return MembershipDto::fromArray($membership);
29
                },
30
                $data['memberships']
31
            ),
32
            $data['name'],
33
            $data['profilePicture'],
34
            UserSettingsDto::fromArray($data['settings']),
35
            new UserStatus($data['status'])
36
        );
37
    }
38
39
    /**
40
     * @param MembershipDto[] $memberships
41
     */
42
    public function __construct(
43
        string $activeWorkspace,
44
        string $defaultWorkspace,
45
        string $email,
46
        string $id,
47
        array $memberships,
48
        string $name,
49
        string $profilePicture,
50
        UserSettingsDto $settings,
51
        UserStatus $status
52
    ) {
53
        $this->activeWorkspace = $activeWorkspace;
54
        $this->defaultWorkspace = $defaultWorkspace;
55
        $this->email = $email;
56
        $this->id = $id;
57
        $this->memberships = $memberships;
58
        $this->name = $name;
59
        $this->profilePicture = $profilePicture;
60
        $this->settings = $settings;
61
        $this->status = $status;
62
    }
63
64
    public function activeWorkspace(): string
65
    {
66
        return $this->activeWorkspace;
67
    }
68
69
    public function defaultWorkspace(): string
70
    {
71
        return $this->defaultWorkspace;
72
    }
73
74
    public function email(): string
75
    {
76
        return $this->email;
77
    }
78
79
    public function id(): string
80
    {
81
        return $this->id;
82
    }
83
84
    /**
85
     * @return MembershipDto[]
86
     */
87
    public function memberships(): array
88
    {
89
        return $this->memberships;
90
    }
91
92
    public function name(): string
93
    {
94
        return $this->name;
95
    }
96
97
    public function profilePicture(): string
98
    {
99
        return $this->profilePicture;
100
    }
101
102
    public function settings(): UserSettingsDto
103
    {
104
        return $this->settings;
105
    }
106
107
    public function status(): UserStatus
108
    {
109
        return $this->status;
110
    }
111
}
112