Passed
Push — main ( fd42c3...1e6836 )
by Iain
04:09
created

SubscriptionPlan::setTrialLengthDays()   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
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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 Doctrine\Common\Collections\ArrayCollection;
18
use Doctrine\Common\Collections\Collection;
19
use Parthenon\Athena\Entity\CrudEntityInterface;
20
21
class SubscriptionPlan implements CrudEntityInterface
22
{
23
    private $id;
24
25
    private bool $public = false;
26
27
    private string $name;
28
29
    private ?string $externalReference = null;
30
31
    private ?string $paymentProviderDetailsLink = null;
32
33
    private array|Collection $limits;
34
35
    private bool $perSeat;
36
37
    private bool $free;
38
39
    private int $userCount;
40
41
    private ?bool $hasTrial = false;
42
43
    private ?int $trialLengthDays = 0;
44
45
    private array|Collection $features;
46
47
    private array|Collection $prices;
48
49
    private Product $product;
50
51
    public function __construct()
52
    {
53
        $this->limits = new ArrayCollection();
54
        $this->features = new ArrayCollection();
55
        $this->prices = new ArrayCollection();
56
    }
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 isPublic(): bool
75
    {
76
        return $this->public;
77
    }
78
79
    public function setPublic(bool $public): void
80
    {
81
        $this->public = $public;
82
    }
83
84
    public function getName(): string
85
    {
86
        return $this->name;
87
    }
88
89
    public function setName(string $name): void
90
    {
91
        $this->name = $name;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getExternalReference(): ?string
98
    {
99
        return $this->externalReference;
100
    }
101
102
    public function setExternalReference(string $externalReference): void
103
    {
104
        $this->externalReference = $externalReference;
105
    }
106
107
    public function hasExternalReference(): bool
108
    {
109
        return isset($this->externalReference);
110
    }
111
112
    public function getPaymentProviderDetailsLink(): ?string
113
    {
114
        return $this->paymentProviderDetailsLink;
115
    }
116
117
    public function setPaymentProviderDetailsLink(?string $paymentProviderDetailsLink): void
118
    {
119
        $this->paymentProviderDetailsLink = $paymentProviderDetailsLink;
120
    }
121
122
    public function getLimits(): Collection|array
123
    {
124
        return $this->limits;
125
    }
126
127
    /**
128
     * @param SubscriptionPlanLimit[]|Collection $limits
129
     */
130
    public function setLimits(Collection|array $limits): void
131
    {
132
        $this->limits = $limits;
133
    }
134
135
    public function addLimit(SubscriptionPlanLimit $limit): void
136
    {
137
        if (!$this->limits->contains($limit)) {
138
            $limit->setSubscriptionPlan($this);
139
            $this->limits->add($limit);
140
        }
141
    }
142
143
    public function removeLimit(SubscriptionPlanLimit $limit): void
144
    {
145
        $this->limits->removeElement($limit);
146
    }
147
148
    public function addFeature(SubscriptionFeature $subscriptionFeature): void
149
    {
150
        if (!$this->features->contains($subscriptionFeature)) {
151
            $this->features->add($subscriptionFeature);
152
        }
153
    }
154
155
    public function removeFeature(SubscriptionFeature $subscriptionFeature): void
156
    {
157
        $this->features->removeElement($subscriptionFeature);
158
    }
159
160
    public function addPrice(Price $price): void
161
    {
162
        if (!$this->prices->contains($price)) {
163
            $this->prices->add($price);
164
        }
165
    }
166
167
    public function removePrice(Price $price): void
168
    {
169
        $this->prices->removeElement($price);
170
    }
171
172
    public function getPrices(): Collection|array
173
    {
174
        return $this->prices;
175
    }
176
177
    public function setPrices(Collection|array $prices): void
178
    {
179
        $this->prices = $prices;
180
    }
181
182
    public function getDisplayName(): string
183
    {
184
        return $this->name;
185
    }
186
187
    public function isPerSeat(): bool
188
    {
189
        return $this->perSeat;
190
    }
191
192
    public function setPerSeat(bool $perSeat): void
193
    {
194
        $this->perSeat = $perSeat;
195
    }
196
197
    public function isFree(): bool
198
    {
199
        return $this->free;
200
    }
201
202
    public function setFree(bool $free): void
203
    {
204
        $this->free = $free;
205
    }
206
207
    public function getUserCount(): int
208
    {
209
        return $this->userCount;
210
    }
211
212
    public function setUserCount(int $userCount): void
213
    {
214
        $this->userCount = $userCount;
215
    }
216
217
    public function getFeatures(): Collection|array
218
    {
219
        return $this->features;
220
    }
221
222
    public function setFeatures(Collection|array $features): void
223
    {
224
        $this->features = $features;
225
    }
226
227
    public function getProduct(): Product
228
    {
229
        return $this->product;
230
    }
231
232
    public function setProduct(Product $product): void
233
    {
234
        $this->product = $product;
235
    }
236
237
    public function getHasTrial(): ?bool
238
    {
239
        return $this->hasTrial;
240
    }
241
242
    public function setHasTrial(?bool $hasTrial): void
243
    {
244
        $this->hasTrial = $hasTrial;
245
    }
246
247
    public function getTrialLengthDays(): ?int
248
    {
249
        return $this->trialLengthDays;
250
    }
251
252
    public function setTrialLengthDays(?int $trialLengthDays): void
253
    {
254
        $this->trialLengthDays = $trialLengthDays;
255
    }
256
}
257