1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This software may be modified and distributed under the terms |
7
|
|
|
* of the MIT license. See the LICENSE file for details. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Shapin\Stripe\Model\Account; |
11
|
|
|
|
12
|
|
|
use Shapin\Stripe\Model\ContainsMetadata; |
13
|
|
|
use Shapin\Stripe\Model\CreatableFromArray; |
14
|
|
|
use Shapin\Stripe\Model\MetadataTrait; |
15
|
|
|
use Shapin\Stripe\Model\MetadataCollection; |
16
|
|
|
use Money\Currency; |
17
|
|
|
|
18
|
|
|
final class Account implements CreatableFromArray, ContainsMetadata |
19
|
|
|
{ |
20
|
|
|
use MetadataTrait; |
21
|
|
|
|
22
|
|
|
const BUSINESS_TYPE_INDIVIDUAL = 'individual'; |
23
|
|
|
const BUSINESS_TYPE_COMPANY = 'company'; |
24
|
|
|
|
25
|
|
|
const TYPE_CUSTOM = 'custom'; |
26
|
|
|
const TYPE_STANDARD = 'standard'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $id; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var ?BusinessProfile |
35
|
|
|
*/ |
36
|
|
|
private $businessProfile; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var ?string |
40
|
|
|
*/ |
41
|
|
|
private $businessType; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var array |
45
|
|
|
*/ |
46
|
|
|
private $capabilities; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var bool |
50
|
|
|
*/ |
51
|
|
|
private $chargesEnabled; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var ?Company |
55
|
|
|
*/ |
56
|
|
|
private $company; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
private $country; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var ?\DateTimeImmutable |
65
|
|
|
*/ |
66
|
|
|
private $createdAt; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var Currency |
70
|
|
|
*/ |
71
|
|
|
private $defaultCurrency; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var bool |
75
|
|
|
*/ |
76
|
|
|
private $detailsSubmitted; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var string |
80
|
|
|
*/ |
81
|
|
|
private $email; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var ExternalAccountCollection |
85
|
|
|
*/ |
86
|
|
|
private $externalAccounts; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @var ?Individual |
90
|
|
|
*/ |
91
|
|
|
private $individual; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @var bool |
95
|
|
|
*/ |
96
|
|
|
private $payoutsEnabled; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @var ?Requirements |
100
|
|
|
*/ |
101
|
|
|
private $requirements; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @var Settings |
105
|
|
|
*/ |
106
|
|
|
private $settings; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @var ?TermsOfServiceAcceptance |
110
|
|
|
*/ |
111
|
|
|
private $termsOfServiceAcceptance; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @var string |
115
|
|
|
*/ |
116
|
|
|
private $type; |
117
|
|
|
|
118
|
5 |
|
public static function createFromArray(array $data): self |
119
|
|
|
{ |
120
|
5 |
|
$model = new self(); |
121
|
5 |
|
$model->id = $data['id']; |
122
|
5 |
|
$model->businessProfile = isset($data['business_profile']) ? BusinessProfile::createFromArray($data['business_profile']) : null; |
123
|
5 |
|
$model->businessType = $data['business_type'] ?? null; |
124
|
5 |
|
$model->capabilities = $data['capabilities'] ?? []; |
125
|
5 |
|
$model->chargesEnabled = (bool) $data['charges_enabled']; |
126
|
5 |
|
$model->company = isset($data['company']) ? Company::createFromArray($data['company']) : null; |
127
|
5 |
|
$model->country = $data['country']; |
128
|
5 |
|
$model->createdAt = isset($data['created']) ? new \DateTimeImmutable('@'.$data['created']) : null; |
129
|
5 |
|
$model->defaultCurrency = new Currency(strtoupper($data['default_currency'])); |
130
|
5 |
|
$model->detailsSubmitted = (bool) $data['details_submitted']; |
131
|
5 |
|
$model->email = $data['email']; |
132
|
5 |
|
$model->externalAccounts = ExternalAccountCollection::createFromArray($data['external_accounts'] ?? []); |
|
|
|
|
133
|
5 |
|
$model->individual = isset($data['individual']) ? Individual::createFromArray($data['individual']) : null; |
134
|
5 |
|
$model->metadata = MetadataCollection::createFromArray($data['metadata'] ?? [] ?? []); |
|
|
|
|
135
|
5 |
|
$model->payoutsEnabled = (bool) $data['payouts_enabled']; |
136
|
5 |
|
$model->requirements = isset($data['requirements']) ? Requirements::createFromArray($data['requirements']) : null; |
137
|
5 |
|
$model->settings = Settings::createFromArray($data['settings']); |
138
|
5 |
|
$model->termsOfServiceAcceptance = isset($data['tos_acceptance']) ? TermsOfServiceAcceptance::createFromArray($data['tos_acceptance']) : null; |
139
|
5 |
|
$model->type = $data['type']; |
140
|
|
|
|
141
|
5 |
|
return $model; |
142
|
|
|
} |
143
|
|
|
|
144
|
1 |
|
public function getId(): string |
145
|
|
|
{ |
146
|
1 |
|
return $this->id; |
147
|
|
|
} |
148
|
|
|
|
149
|
1 |
|
public function getBusinessProfile(): ?BusinessProfile |
150
|
|
|
{ |
151
|
1 |
|
return $this->businessProfile; |
152
|
|
|
} |
153
|
|
|
|
154
|
1 |
|
public function getBusinessType(): ?string |
155
|
|
|
{ |
156
|
1 |
|
return $this->businessType; |
157
|
|
|
} |
158
|
|
|
|
159
|
1 |
|
public function getCapabilities(): array |
160
|
|
|
{ |
161
|
1 |
|
return $this->capabilities; |
162
|
|
|
} |
163
|
|
|
|
164
|
1 |
|
public function areChargesEnabled(): bool |
165
|
|
|
{ |
166
|
1 |
|
return $this->chargesEnabled; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
public function getCompany(): ?Company |
170
|
|
|
{ |
171
|
|
|
return $this->company; |
172
|
|
|
} |
173
|
|
|
|
174
|
1 |
|
public function getCountry(): string |
175
|
|
|
{ |
176
|
1 |
|
return $this->country; |
177
|
|
|
} |
178
|
|
|
|
179
|
1 |
|
public function getCreatedAt(): ?\DateTimeImmutable |
180
|
|
|
{ |
181
|
1 |
|
return $this->createdAt; |
182
|
|
|
} |
183
|
|
|
|
184
|
1 |
|
public function getDefaultCurrency(): Currency |
185
|
|
|
{ |
186
|
1 |
|
return $this->defaultCurrency; |
187
|
|
|
} |
188
|
|
|
|
189
|
1 |
|
public function areDetailsSubmitted(): bool |
190
|
|
|
{ |
191
|
1 |
|
return $this->detailsSubmitted; |
192
|
|
|
} |
193
|
|
|
|
194
|
1 |
|
public function getEmail(): string |
195
|
|
|
{ |
196
|
1 |
|
return $this->email; |
197
|
|
|
} |
198
|
|
|
|
199
|
1 |
|
public function getExternalAccounts(): ExternalAccountCollection |
200
|
|
|
{ |
201
|
1 |
|
return $this->externalAccounts; |
202
|
|
|
} |
203
|
|
|
|
204
|
1 |
|
public function getIndividual(): ?Individual |
205
|
|
|
{ |
206
|
1 |
|
return $this->individual; |
207
|
|
|
} |
208
|
|
|
|
209
|
1 |
|
public function arePayoutsEnabled(): bool |
210
|
|
|
{ |
211
|
1 |
|
return $this->payoutsEnabled; |
212
|
|
|
} |
213
|
|
|
|
214
|
1 |
|
public function getRequirements(): ?Requirements |
215
|
|
|
{ |
216
|
1 |
|
return $this->requirements; |
217
|
|
|
} |
218
|
|
|
|
219
|
1 |
|
public function getSettings(): Settings |
220
|
|
|
{ |
221
|
1 |
|
return $this->settings; |
222
|
|
|
} |
223
|
|
|
|
224
|
1 |
|
public function getTermsOfServiceAcceptance(): ?TermsOfServiceAcceptance |
225
|
|
|
{ |
226
|
1 |
|
return $this->termsOfServiceAcceptance; |
227
|
|
|
} |
228
|
|
|
|
229
|
1 |
|
public function getType(): string |
230
|
|
|
{ |
231
|
1 |
|
return $this->type; |
232
|
|
|
} |
233
|
|
|
} |
234
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..