1 | <?php |
||
2 | /** |
||
3 | * Payment.php |
||
4 | * Copyright (c) 2018 [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 | |||
22 | declare(strict_types=1); |
||
23 | |||
24 | namespace FireflyIII\Services\Bunq\Object; |
||
25 | |||
26 | use Carbon\Carbon; |
||
27 | |||
28 | |||
29 | /** |
||
30 | * Class Payment |
||
31 | */ |
||
32 | class Payment extends BunqObject |
||
33 | { |
||
34 | /** @var LabelMonetaryAccount */ |
||
35 | private $alias; |
||
36 | /** @var Amount */ |
||
37 | private $amount; |
||
38 | /** @var array */ |
||
39 | private $attachments = []; |
||
40 | /** @var LabelMonetaryAccount */ |
||
41 | private $counterParty; |
||
42 | /** @var Carbon */ |
||
43 | private $created; |
||
44 | /** @var string */ |
||
45 | private $description; |
||
46 | /** @var int */ |
||
47 | private $id; |
||
48 | /** @var string */ |
||
49 | private $merchantReference; |
||
50 | /** @var int */ |
||
51 | private $monetaryAccountId; |
||
52 | /** @var string */ |
||
53 | private $subType; |
||
54 | /** @var string */ |
||
55 | private $type; |
||
56 | /** @var Carbon */ |
||
57 | private $updated; |
||
58 | |||
59 | /** |
||
60 | * Payment constructor. |
||
61 | * |
||
62 | * @param array $data |
||
63 | * |
||
64 | */ |
||
65 | public function __construct(array $data) |
||
66 | { |
||
67 | $this->id = $data['id']; |
||
68 | $this->created = Carbon::createFromFormat('Y-m-d H:i:s.u', $data['created']); |
||
69 | $this->updated = Carbon::createFromFormat('Y-m-d H:i:s.u', $data['updated']); |
||
70 | $this->monetaryAccountId = (int)$data['monetary_account_id']; |
||
71 | $this->amount = new Amount($data['amount']); |
||
72 | $this->description = $data['description']; |
||
73 | $this->type = $data['type']; |
||
74 | $this->merchantReference = $data['merchant_reference']; |
||
75 | $this->alias = new LabelMonetaryAccount($data['alias']); |
||
76 | $this->counterParty = new LabelMonetaryAccount($data['counterparty_alias']); |
||
77 | $this->subType = $data['sub_type']; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return Amount |
||
82 | */ |
||
83 | public function getAmount(): Amount |
||
84 | { |
||
85 | return $this->amount; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @return LabelMonetaryAccount|null |
||
90 | */ |
||
91 | public function getCounterParty(): ?LabelMonetaryAccount |
||
92 | { |
||
93 | return $this->counterParty; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @return Carbon |
||
98 | */ |
||
99 | public function getCreated(): Carbon |
||
100 | { |
||
101 | return $this->created; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getDescription(): string |
||
108 | { |
||
109 | return $this->description; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @return int |
||
114 | */ |
||
115 | public function getId(): int |
||
116 | { |
||
117 | return $this->id; |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * @return string |
||
122 | */ |
||
123 | public function getSubType(): string |
||
124 | { |
||
125 | return $this->subType; |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * @return string |
||
130 | */ |
||
131 | public function getType(): string |
||
132 | { |
||
133 | return $this->type; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @return array |
||
138 | */ |
||
139 | public function toArray(): array |
||
140 | { |
||
141 | die(sprintf('Cannot convert %s to array.', get_class($this))); |
||
0 ignored issues
–
show
|
|||
142 | } |
||
143 | |||
144 | } |
||
145 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.