Passed
Push — main ( ffb381...09672f )
by Iain
04:55
created

Subscription::getMainExternalReference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright Iain Cambridge 2020-2023.
7
 *
8
 * Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license.
9
 *
10
 * Change Date: TBD ( 3 years after 2.2.0 release )
11
 *
12
 * On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file.
13
 */
14
15
namespace Parthenon\Billing\Entity;
16
17
use Brick\Money\Currency;
18
use Brick\Money\Money;
19
20
class Subscription
21
{
22
    private $id;
23
24
    private CustomerInterface $customer;
25
26
    private string $planName;
27
28
    private string $paymentSchedule;
29
30
    private bool $mainSubscription = true;
31
32
    private ?int $seats = 1;
33
34
    private bool $active;
35
36
    private string $status;
37
38
    private ?int $amount = null;
39
40
    private ?string $currency = null;
41
42
    private string $mainExternalReference;
43
44
    private string $childExternalReference;
45
46
    private ?SubscriptionPlan $subscriptionPlan = null;
47
48
    private ?Price $price = null;
49
50
    private \DateTimeInterface $createdAt;
51
52
    private ?\DateTimeInterface $validUntil = null;
53
54
    private \DateTimeInterface $updatedAt;
55
56
    private ?\DateTimeInterface $endedAt = null;
57
58
    /**
59
     * @return mixed
60
     */
61
    public function getId()
62
    {
63
        return $this->id;
64
    }
65
66
    /**
67
     * @param mixed $id
68
     */
69
    public function setId($id): void
70
    {
71
        $this->id = $id;
72
    }
73
74
    public function getPlanName(): string
75
    {
76
        return $this->planName;
77
    }
78
79
    public function setPlanName(string $planName): void
80
    {
81
        $this->planName = $planName;
82
    }
83
84
    public function getPaymentSchedule(): string
85
    {
86
        return $this->paymentSchedule;
87
    }
88
89
    public function setPaymentSchedule(string $paymentSchedule): void
90
    {
91
        $this->paymentSchedule = $paymentSchedule;
92
    }
93
94
    public function getSeats(): ?int
95
    {
96
        return $this->seats;
97
    }
98
99
    public function setSeats(?int $seats): void
100
    {
101
        $this->seats = $seats;
102
    }
103
104
    public function getStatus(): string
105
    {
106
        return $this->status;
107
    }
108
109
    public function setStatus(string $status): void
110
    {
111
        $this->status = $status;
112
    }
113
114
    public function getSubscriptionPlan(): ?SubscriptionPlan
115
    {
116
        return $this->subscriptionPlan;
117
    }
118
119
    public function setSubscriptionPlan(?SubscriptionPlan $subscriptionPlan): void
120
    {
121
        $this->subscriptionPlan = $subscriptionPlan;
122
    }
123
124
    public function isMainSubscription(): bool
125
    {
126
        return $this->mainSubscription;
127
    }
128
129
    public function setMainSubscription(bool $mainSubscription): void
130
    {
131
        $this->mainSubscription = $mainSubscription;
132
    }
133
134
    public function getMainExternalReference(): string
135
    {
136
        return $this->mainExternalReference;
137
    }
138
139
    public function setMainExternalReference(string $mainExternalReference): void
140
    {
141
        $this->mainExternalReference = $mainExternalReference;
142
    }
143
144
    public function getChildExternalReference(): string
145
    {
146
        return $this->childExternalReference;
147
    }
148
149
    public function setChildExternalReference(string $childExternalReference): void
150
    {
151
        $this->childExternalReference = $childExternalReference;
152
    }
153
154
    public function getAmount(): ?int
155
    {
156
        return $this->amount;
157
    }
158
159
    public function setAmount(?int $amount): void
160
    {
161
        $this->amount = $amount;
162
    }
163
164
    public function getCurrency(): ?string
165
    {
166
        return $this->currency;
167
    }
168
169
    public function setCurrency(?string $currency): void
170
    {
171
        $this->currency = $currency;
172
    }
173
174
    public function getPrice(): ?Price
175
    {
176
        return $this->price;
177
    }
178
179
    public function setPrice(?Price $price): void
180
    {
181
        $this->price = $price;
182
    }
183
184
    public function getCreatedAt(): \DateTimeInterface
185
    {
186
        return $this->createdAt;
187
    }
188
189
    public function setCreatedAt(\DateTimeInterface $createdAt): void
190
    {
191
        $this->createdAt = $createdAt;
192
    }
193
194
    public function getUpdatedAt(): \DateTimeInterface
195
    {
196
        return $this->updatedAt;
197
    }
198
199
    public function setUpdatedAt(\DateTimeInterface $updatedAt): void
200
    {
201
        $this->updatedAt = $updatedAt;
202
    }
203
204
    public function getEndedAt(): ?\DateTimeInterface
205
    {
206
        return $this->endedAt;
207
    }
208
209
    public function setEndedAt(?\DateTimeInterface $endedAt): void
210
    {
211
        $this->endedAt = $endedAt;
212
    }
213
214
    public function isActive(): bool
215
    {
216
        return $this->active;
217
    }
218
219
    public function setActive(bool $active): void
220
    {
221
        $this->active = $active;
222
    }
223
224
    public function getValidUntil(): \DateTimeInterface
225
    {
226
        return $this->validUntil;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->validUntil could return the type null which is incompatible with the type-hinted return DateTimeInterface. Consider adding an additional type-check to rule them out.
Loading history...
227
    }
228
229
    public function setValidUntil(\DateTimeInterface $validUntil): void
230
    {
231
        $this->validUntil = $validUntil;
232
    }
233
234
    public function getMoneyAmount(): Money
235
    {
236
        return Money::ofMinor($this->amount, Currency::of($this->currency));
237
    }
238
239
    public function setMoneyAmount(Money $money)
240
    {
241
        $this->amount = $money->getAmount()->getUnscaledValue()->toInt();
242
        $this->currency = $money->getCurrency()->getCurrencyCode();
243
    }
244
245
    public function getCustomer(): CustomerInterface
246
    {
247
        return $this->customer;
248
    }
249
250
    public function setCustomer(CustomerInterface $customer): void
251
    {
252
        $this->customer = $customer;
253
    }
254
}
255