Completed
Push — master ( e2218d...b273ad )
by Olivier
12s queued 10s
created

Account::getIndividual()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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 Money\Currency;
13
use Shapin\Stripe\Model\ContainsMetadata;
14
use Shapin\Stripe\Model\CreatableFromArray;
15
use Shapin\Stripe\Model\MetadataCollection;
16
use Shapin\Stripe\Model\MetadataTrait;
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 bool
90
     */
91
    private $payoutsEnabled;
92
93
    /**
94
     * @var ?Requirements
95
     */
96
    private $requirements;
97
98
    /**
99
     * @var Settings
100
     */
101
    private $settings;
102
103
    /**
104
     * @var ?TermsOfServiceAcceptance
105
     */
106
    private $termsOfServiceAcceptance;
107
108
    /**
109
     * @var string
110
     */
111
    private $type;
112
113 4
    public static function createFromArray(array $data): self
114
    {
115 4
        $model = new self();
116 4
        $model->id = $data['id'];
117 4
        $model->businessProfile = isset($data['business_profile']) ? BusinessProfile::createFromArray($data['business_profile']) : null;
118 4
        $model->businessType = $data['business_type'] ?? null;
119 4
        $model->capabilities = $data['capabilities'] ?? [];
120 4
        $model->chargesEnabled = (bool) $data['charges_enabled'];
121 4
        $model->company = isset($data['company']) ? Company::createFromArray($data['company']) : null;
122 4
        $model->country = $data['country'];
123 4
        $model->createdAt = isset($data['created']) ? new \DateTimeImmutable('@'.$data['created']) : null;
124 4
        $model->defaultCurrency = new Currency(strtoupper($data['default_currency']));
125 4
        $model->detailsSubmitted = (bool) $data['details_submitted'];
126 4
        $model->email = $data['email'];
127 4
        $model->externalAccounts = ExternalAccountCollection::createFromArray($data['external_accounts'] ?? []);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Acc..._accounts'] ?? array()) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Mod...ernalAccountCollection> of property $externalAccounts.

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..

Loading history...
128 4
        $model->metadata = MetadataCollection::createFromArray($data['metadata'] ?? [] ?? []);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Met... ?? array() ?? array()) of type object<self> is incompatible with the declared type object<Shapin\Stripe\Model\MetadataCollection> of property $metadata.

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..

Loading history...
129 4
        $model->payoutsEnabled = (bool) $data['payouts_enabled'];
130 4
        $model->requirements = isset($data['requirements']) ? Requirements::createFromArray($data['requirements']) : null;
131 4
        $model->settings = Settings::createFromArray($data['settings']);
132 4
        $model->termsOfServiceAcceptance = isset($data['tos_acceptance']) ? TermsOfServiceAcceptance::createFromArray($data['tos_acceptance']) : null;
133 4
        $model->type = $data['type'];
134
135 4
        return $model;
136
    }
137
138 1
    public function getId(): string
139
    {
140 1
        return $this->id;
141
    }
142
143 1
    public function getBusinessProfile(): ?BusinessProfile
144
    {
145 1
        return $this->businessProfile;
146
    }
147
148 1
    public function getBusinessType(): ?string
149
    {
150 1
        return $this->businessType;
151
    }
152
153 1
    public function getCapabilities(): array
154
    {
155 1
        return $this->capabilities;
156
    }
157
158 1
    public function areChargesEnabled(): bool
159
    {
160 1
        return $this->chargesEnabled;
161
    }
162
163
    public function getCompany(): ?Company
164
    {
165
        return $this->company;
166
    }
167
168 1
    public function getCountry(): string
169
    {
170 1
        return $this->country;
171
    }
172
173 1
    public function getCreatedAt(): ?\DateTimeImmutable
174
    {
175 1
        return $this->createdAt;
176
    }
177
178 1
    public function getDefaultCurrency(): Currency
179
    {
180 1
        return $this->defaultCurrency;
181
    }
182
183 1
    public function areDetailsSubmitted(): bool
184
    {
185 1
        return $this->detailsSubmitted;
186
    }
187
188 1
    public function getEmail(): string
189
    {
190 1
        return $this->email;
191
    }
192
193 1
    public function getExternalAccounts(): ExternalAccountCollection
194
    {
195 1
        return $this->externalAccounts;
196
    }
197
198 1
    public function arePayoutsEnabled(): bool
199
    {
200 1
        return $this->payoutsEnabled;
201
    }
202
203 1
    public function getRequirements(): ?Requirements
204
    {
205 1
        return $this->requirements;
206
    }
207
208 1
    public function getSettings(): Settings
209
    {
210 1
        return $this->settings;
211
    }
212
213 1
    public function getTermsOfServiceAcceptance(): ?TermsOfServiceAcceptance
214
    {
215 1
        return $this->termsOfServiceAcceptance;
216
    }
217
218 1
    public function getType(): string
219
    {
220 1
        return $this->type;
221
    }
222
}
223