Passed
Push — main ( dd3965...a39777 )
by Iain
04:35
created

SubscriptionPlan::__construct()   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 0
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 $externalReferenceLink = null;
32
33
    private array|Collection $limits;
34
35
    public function __construct()
36
    {
37
        $this->limits = new ArrayCollection();
38
    }
39
40
    /**
41
     * @return mixed
42
     */
43
    public function getId()
44
    {
45
        return $this->id;
46
    }
47
48
    /**
49
     * @param mixed $id
50
     */
51
    public function setId($id): void
52
    {
53
        $this->id = $id;
54
    }
55
56
    public function isPublic(): bool
57
    {
58
        return $this->public;
59
    }
60
61
    public function setPublic(bool $public): void
62
    {
63
        $this->public = $public;
64
    }
65
66
    public function getName(): string
67
    {
68
        return $this->name;
69
    }
70
71
    public function setName(string $name): void
72
    {
73
        $this->name = $name;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getExternalReference(): ?string
80
    {
81
        return $this->externalReference;
82
    }
83
84
    public function setExternalReference(string $externalReference): void
85
    {
86
        $this->externalReference = $externalReference;
87
    }
88
89
    public function hasExternalReference(): bool
90
    {
91
        return isset($this->externalReference);
92
    }
93
94
    public function getExternalReferenceLink(): ?string
95
    {
96
        return $this->externalReferenceLink;
97
    }
98
99
    public function setExternalReferenceLink(?string $externalReferenceLink): void
100
    {
101
        $this->externalReferenceLink = $externalReferenceLink;
102
    }
103
104
    public function getLimits(): Collection|array
105
    {
106
        return $this->limits;
107
    }
108
109
    /**
110
     * @param SubscriptionPlanLimit[]|Collection $limits
111
     */
112
    public function setLimits(Collection|array $limits): void
113
    {
114
        $this->limits = $limits;
115
    }
116
117
    public function addLimit(SubscriptionPlanLimit $limit): void
118
    {
119
        if (!$this->limits->contains($limit)) {
120
            $limit->setSubscriptionPlan($this);
121
            $this->limits->add($limit);
122
        }
123
    }
124
125
    public function removeLimit(SubscriptionPlanLimit $limit): void
126
    {
127
        $this->limits->removeElement($limit);
128
    }
129
130
    public function getDisplayName(): string
131
    {
132
        return $this->name;
133
    }
134
}
135