Passed
Push — main ( bfdcab...77b434 )
by Iain
04:25
created

SubscriptionPlan::setProduct()   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 1
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 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 array|Collection $features;
42
    private array|Collection $prices;
43
    private Product $product;
44
45
    public function __construct()
46
    {
47
        $this->limits = new ArrayCollection();
48
        $this->features = new ArrayCollection();
49
        $this->prices = new ArrayCollection();
50
    }
51
52
    /**
53
     * @return mixed
54
     */
55
    public function getId()
56
    {
57
        return $this->id;
58
    }
59
60
    /**
61
     * @param mixed $id
62
     */
63
    public function setId($id): void
64
    {
65
        $this->id = $id;
66
    }
67
68
    public function isPublic(): bool
69
    {
70
        return $this->public;
71
    }
72
73
    public function setPublic(bool $public): void
74
    {
75
        $this->public = $public;
76
    }
77
78
    public function getName(): string
79
    {
80
        return $this->name;
81
    }
82
83
    public function setName(string $name): void
84
    {
85
        $this->name = $name;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getExternalReference(): ?string
92
    {
93
        return $this->externalReference;
94
    }
95
96
    public function setExternalReference(string $externalReference): void
97
    {
98
        $this->externalReference = $externalReference;
99
    }
100
101
    public function hasExternalReference(): bool
102
    {
103
        return isset($this->externalReference);
104
    }
105
106
    public function getPaymentProviderDetailsLink(): ?string
107
    {
108
        return $this->paymentProviderDetailsLink;
109
    }
110
111
    public function setPaymentProviderDetailsLink(?string $paymentProviderDetailsLink): void
112
    {
113
        $this->paymentProviderDetailsLink = $paymentProviderDetailsLink;
114
    }
115
116
    public function getLimits(): Collection|array
117
    {
118
        return $this->limits;
119
    }
120
121
    /**
122
     * @param SubscriptionPlanLimit[]|Collection $limits
123
     */
124
    public function setLimits(Collection|array $limits): void
125
    {
126
        $this->limits = $limits;
127
    }
128
129
    public function addLimit(SubscriptionPlanLimit $limit): void
130
    {
131
        if (!$this->limits->contains($limit)) {
132
            $limit->setSubscriptionPlan($this);
133
            $this->limits->add($limit);
134
        }
135
    }
136
137
    public function removeLimit(SubscriptionPlanLimit $limit): void
138
    {
139
        $this->limits->removeElement($limit);
140
    }
141
142
    public function addFeature(SubscriptionFeature $subscriptionFeature): void
143
    {
144
        if (!$this->features->contains($subscriptionFeature)) {
145
            $this->features->add($subscriptionFeature);
146
        }
147
    }
148
149
    public function removeFeature(SubscriptionFeature $subscriptionFeature): void
150
    {
151
        $this->features->removeElement($subscriptionFeature);
152
    }
153
154
    public function addPrice(Price $price): void
155
    {
156
        if (!$this->prices->contains($price)) {
157
            $this->prices->add($price);
158
        }
159
    }
160
161
    public function removePrice(Price $price): void
162
    {
163
        $this->prices->removeElement($price);
164
    }
165
166
    public function getPrices(): Collection|array
167
    {
168
        return $this->prices;
169
    }
170
171
    public function setPrices(Collection|array $prices): void
172
    {
173
        $this->prices = $prices;
174
    }
175
176
    public function getDisplayName(): string
177
    {
178
        return $this->name;
179
    }
180
181
    public function isPerSeat(): bool
182
    {
183
        return $this->perSeat;
184
    }
185
186
    public function setPerSeat(bool $perSeat): void
187
    {
188
        $this->perSeat = $perSeat;
189
    }
190
191
    public function isFree(): bool
192
    {
193
        return $this->free;
194
    }
195
196
    public function setFree(bool $free): void
197
    {
198
        $this->free = $free;
199
    }
200
201
    public function getUserCount(): int
202
    {
203
        return $this->userCount;
204
    }
205
206
    public function setUserCount(int $userCount): void
207
    {
208
        $this->userCount = $userCount;
209
    }
210
211
    public function getFeatures(): Collection|array
212
    {
213
        return $this->features;
214
    }
215
216
    public function setFeatures(Collection|array $features): void
217
    {
218
        $this->features = $features;
219
    }
220
221
    public function getProduct(): Product
222
    {
223
        return $this->product;
224
    }
225
226
    public function setProduct(Product $product): void
227
    {
228
        $this->product = $product;
229
    }
230
}
231