1 | <?php |
||
2 | /** |
||
3 | * UserLight.php |
||
4 | * Copyright (c) 2017 [email protected] |
||
5 | * |
||
6 | * This file is part of Firefly III. |
||
7 | * |
||
8 | * Firefly III is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU General Public License as published by |
||
10 | * the Free Software Foundation, either version 3 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * Firefly III is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU General Public License |
||
19 | * along with Firefly III. If not, see <http://www.gnu.org/licenses/>. |
||
20 | */ |
||
21 | declare(strict_types=1); |
||
22 | |||
23 | namespace FireflyIII\Services\Bunq\Object; |
||
24 | |||
25 | use Carbon\Carbon; |
||
26 | |||
27 | /** |
||
28 | * Class UserLight. |
||
29 | */ |
||
30 | class UserLight extends BunqObject |
||
31 | { |
||
32 | /** @var array */ |
||
33 | private $aliases = []; |
||
34 | /** @var Carbon */ |
||
35 | private $created; |
||
36 | /** @var string */ |
||
37 | private $displayName; |
||
38 | /** @var string */ |
||
39 | private $firstName; |
||
40 | /** @var int */ |
||
41 | private $id; |
||
42 | /** @var string */ |
||
43 | private $lastName; |
||
44 | /** @var string */ |
||
45 | private $legalName; |
||
46 | /** @var string */ |
||
47 | private $middleName; |
||
48 | /** @var string */ |
||
49 | private $publicNickName; |
||
50 | /** @var string */ |
||
51 | private $publicUuid; |
||
52 | /** @var Carbon */ |
||
53 | private $updated; |
||
54 | |||
55 | /** |
||
56 | * UserLight constructor. |
||
57 | * |
||
58 | * @param array $data |
||
59 | * |
||
60 | */ |
||
61 | public function __construct(array $data) |
||
62 | { |
||
63 | if (0 === count($data)) { |
||
64 | return; |
||
65 | } |
||
66 | $this->id = (int)$data['id']; |
||
67 | $this->created = Carbon::createFromFormat('Y-m-d H:i:s.u', $data['created']); |
||
68 | $this->updated = Carbon::createFromFormat('Y-m-d H:i:s.u', $data['updated']); |
||
69 | $this->publicUuid = $data['public_uuid']; |
||
70 | $this->displayName = $data['display_name']; |
||
71 | $this->publicNickName = $data['public_nick_name']; |
||
72 | $this->firstName = $data['first_name']; |
||
73 | $this->middleName = $data['middle_name']; |
||
74 | $this->lastName = $data['last_name']; |
||
75 | $this->legalName = $data['legal_name']; |
||
76 | // aliases |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @return array |
||
81 | */ |
||
82 | public function toArray(): array |
||
83 | { |
||
84 | die(sprintf('Cannot convert %s to array.', get_class($this))); |
||
0 ignored issues
–
show
|
|||
85 | } |
||
86 | } |
||
87 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.