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

SetupIntent::getLastSetupError()   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\SetupIntent;
11
12
use Shapin\Stripe\Model\ContainsMetadata;
13
use Shapin\Stripe\Model\CreatableFromArray;
14
use Shapin\Stripe\Model\Intent;
15
use Shapin\Stripe\Model\IntentNextAction;
16
use Shapin\Stripe\Model\LivemodeTrait;
17
use Shapin\Stripe\Model\MetadataCollection;
18
use Shapin\Stripe\Model\MetadataTrait;
19
20
final class SetupIntent extends Intent implements CreatableFromArray, ContainsMetadata
21
{
22
    use LivemodeTrait;
23
    use MetadataTrait;
24
25
    const CANCELLATION_REASON_ABANDONED = 'abandoned';
26
    const CANCELLATION_REASON_REQUESTED_BY_CUSTOMER = 'requested_by_customer';
27
    const CANCELLATION_REASON_DUPLICATE = 'duplicate';
28
29
    const USAGE_ON_SESSION = 'on_session';
30
    const USAGE_OFF_SESSION = 'off_session';
31
32
    /**
33
     * @var string
34
     */
35
    private $id;
36
37
    /**
38
     * @var ?string
39
     */
40
    private $applicationId;
41
42
    /**
43
     * @var ?string
44
     */
45
    private $cancellationReason;
46
47
    /**
48
     * @var ?string
49
     */
50
    private $clientSecret;
51
52
    /**
53
     * @var string
54
     */
55
    private $confirmationMethod;
56
57
    /**
58
     * @var \DateTimeImmutable
59
     */
60
    private $createdAt;
61
62
    /**
63
     * @var string
64
     */
65
    private $customerId;
66
67
    /**
68
     * @var string
69
     */
70
    private $description;
71
72
    /**
73
     * @var ?string
74
     */
75
    private $onBehalfOfId;
76
77
    /**
78
     * @var ?string
79
     */
80
    private $paymentMethodId;
81
82
    /**
83
     * @var array
84
     */
85
    private $paymentMethodTypes;
86
87
    /**
88
     * @var string
89
     */
90
    private $usage;
91
92 3
    public static function createFromArray(array $data): self
93
    {
94 3
        $model = new self();
95 3
        $model->id = $data['id'];
96 3
        $model->applicationId = $data['application'];
97 3
        $model->cancellationReason = $data['cancellation_reason'] ?? null;
98 3
        $model->clientSecret = $data['client_secret'];
99 3
        $model->createdAt = new \DateTimeImmutable('@'.$data['created']);
100 3
        $model->customerId = $data['customer'];
101 3
        $model->description = $data['description'];
102 3
        $model->live = $data['livemode'];
103 3
        $model->metadata = MetadataCollection::createFromArray($data['metadata']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Shapin\Stripe\Model\Met...rray($data['metadata']) 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...
104 3
        $model->nextAction = isset($data['next_action']) ? IntentNextAction::createFromArray($data['next_action']) : null;
105 3
        $model->onBehalfOfId = $data['on_behalf_of'];
106 3
        $model->paymentMethodId = $data['payment_method'];
107 3
        $model->paymentMethodTypes = $data['payment_method_types'];
108 3
        $model->status = $data['status'];
109 3
        $model->usage = $data['usage'];
110
111 3
        return $model;
112
    }
113
114 1
    public function getId(): string
115
    {
116 1
        return $this->id;
117
    }
118
119 1
    public function getApplicationId(): ?string
120
    {
121 1
        return $this->applicationId;
122
    }
123
124 1
    public function getCancellationReason(): ?string
125
    {
126 1
        return $this->cancellationReason;
127
    }
128
129 1
    public function getClientSecret(): ?string
130
    {
131 1
        return $this->clientSecret;
132
    }
133
134 1
    public function getCreatedAt(): \DateTimeInterface
135
    {
136 1
        return $this->createdAt;
137
    }
138
139 1
    public function getCustomerId(): ?string
140
    {
141 1
        return $this->customerId;
142
    }
143
144 1
    public function getDescription(): ?string
145
    {
146 1
        return $this->description;
147
    }
148
149 1
    public function getOnBehalfOfId(): ?string
150
    {
151 1
        return $this->onBehalfOfId;
152
    }
153
154 1
    public function getPaymentMethodId(): ?string
155
    {
156 1
        return $this->paymentMethodId;
157
    }
158
159 1
    public function getPaymentMethodTypes(): array
160
    {
161 1
        return $this->paymentMethodTypes;
162
    }
163
164 1
    public function getUsage(): string
165
    {
166 1
        return $this->usage;
167
    }
168
}
169