User::created()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
3
namespace Link0\Bunq\Domain;
4
5
use DateTimeInterface;
6
use DateTimeZone;
7
8
abstract class User
9
{
10
    const STATUS_ACTIVE = 'ACTIVE';
11
    const STATUS_SIGNUP = 'SIGNUP';
12
    const STATUS_RECOVERY = 'RECOVERY';
13
14
    const SUBSTATUS_NONE = 'NONE';
15
    const SUBSTATUS_FACE_RESET = 'FACE_RESET';
16
    const SUBSTATUS_APPROVAL = 'APPROVAL';
17
    const SUBSTATUS_APPROVAL_DIRECTOR = 'APPROVAL_DIRECTOR';
18
    const SUBSTATUS_APPROVAL_PARENT = 'APPROVAL_PARENT';
19
    const SUBSTATUS_APPROVAL_SUPPORT = 'APPROVAL_SUPPORT';
20
    const SUBSTATUS_COUNTER_IBAN = 'COUNTER_IBAN';
21
    const SUBSTATUS_IDEAL = 'IDEAL';
22
    const SUBSTATUS_SUBMIT = 'SUBMIT';
23
24
    /**
25
     * @var Id
26
     */
27
    private $id;
28
29
    /**
30
     * @var string
31
     */
32
    private $status;
33
34
    /**
35
     * @var string
36
     */
37
    private $subStatus;
38
39
    /**
40
     * @var DateTimeInterface
41
     */
42
    private $created;
43
44
    /**
45
     * @var DateTimeInterface
46
     */
47
    private $updated;
48
49
    /**
50
     * @var Alias[]
51
     */
52
    private $alias;
53
54
    /**
55
     * @var string
56
     */
57
    private $publicUuid;
58
59
    /**
60
     * @var string
61
     */
62
    private $nickname;
63
64
    /**
65
     * @var string
66
     */
67
    private $displayName;
68
69
    /**
70
     * @var string
71
     */
72
    private $language;
73
74
    /**
75
     * @var string
76
     */
77
    private $region;
78
79
    /**
80
     * @var int
81
     */
82
    private $sessionTimeout;
83
84
    /**
85
     * @var Address
86
     */
87
    private $mainAddress;
88
89
    /**
90
     * @var Address
91
     */
92
    private $postalAddress;
93
94
    /**
95
     * @var NotificationFilter[]
96
     */
97
    private $notificationFilters;
98
99
    /**
100
     * @param array $user
101
     */
102
    protected function __construct(array $user)
103
    {
104
        $this->id = Id::fromInteger(intval($user['id']));
105
        $this->status = $user['status'];
106
        $this->subStatus = $user['sub_status'];
107
108
        $timezone = new DateTimeZone('UTC');
109
        $this->created = new \DateTimeImmutable($user['created'], $timezone);
110
        $this->updated = new \DateTimeImmutable($user['updated'], $timezone);
111
112
        $this->alias = array_map(function ($alias) {
113
            return Alias::fromArray($alias);
114
        }, $user['alias']);
115
116
        $this->publicUuid = $user['public_uuid'];
117
        $this->nickname = $user['public_nick_name'];
118
        $this->displayName = $user['display_name'];
119
        $this->language = $user['language'];
120
        $this->region = $user['region'];
121
        $this->sessionTimeout = intval($user['session_timeout']);
122
123
        $this->mainAddress = Address::fromArray($user['address_main']);
124
        $this->postalAddress = Address::fromArray($user['address_postal']);
125
126
        $this->notificationFilters = array_map(function ($notificationFilter) {
127
            return NotificationFilter::fromArray($notificationFilter);
128
        }, $user['notification_filters']);
129
    }
130
131
    /**
132
     * @return Id
133
     */
134
    public function id(): Id
135
    {
136
        return $this->id;
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    public function status(): string
143
    {
144
        return $this->status;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    public function subStatus(): string
151
    {
152
        return $this->subStatus;
153
    }
154
155
    /**
156
     * @return DateTimeInterface
157
     */
158
    public function created(): DateTimeInterface
159
    {
160
        return $this->created;
161
    }
162
163
    /**
164
     * @return DateTimeInterface
165
     */
166
    public function updated(): DateTimeInterface
167
    {
168
        return $this->updated;
169
    }
170
171
    /**
172
     * @return Alias[]
173
     */
174
    public function alias(): array
175
    {
176
        return $this->alias;
177
    }
178
179
    /**
180
     * @return string
181
     */
182
    public function publicUuid(): string
183
    {
184
        return $this->publicUuid;
185
    }
186
187
    /**
188
     * @return string
189
     */
190
    public function nickname(): string
191
    {
192
        return $this->nickname;
193
    }
194
195
    /**
196
     * @return string
197
     */
198
    public function displayName(): string
199
    {
200
        return $this->displayName;
201
    }
202
203
    /**
204
     * @return string
205
     */
206
    public function language(): string
207
    {
208
        return $this->language;
209
    }
210
211
    /**
212
     * @return string
213
     */
214
    public function region(): string
215
    {
216
        return $this->region;
217
    }
218
219
    /**
220
     * @return int
221
     */
222
    public function sessionTimeout(): int
223
    {
224
        return $this->sessionTimeout;
225
    }
226
227
    /**
228
     * @return NotificationFilter[]
229
     */
230
    public function notificationFilters(): array
231
    {
232
        return $this->notificationFilters;
233
    }
234
}
235