Passed
Push — main ( a10163...70ec62 )
by Iain
04:24
created

Payment::setSubscription()   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 Brick\Money\Currency;
18
use Brick\Money\Money;
19
20
class Payment
21
{
22
    protected ?string $paymentProviderDetailsUrl;
23
    private $id;
24
25
    private string $paymentReference;
26
27
    private string $provider;
28
29
    private int $amount;
30
31
    private string $currency;
32
33
    private CustomerInterface $customer;
34
35
    private \DateTimeInterface $createdAt;
36
37
    private \DateTimeInterface $updatedAt;
38
39
    private bool $refunded = false;
40
41
    private bool $completed = false;
42
43
    private bool $chargedBack = false;
44
45
    private ?Subscription $subscription = null;
46
47
    /**
48
     * @return mixed
49
     */
50
    public function getId()
51
    {
52
        return $this->id;
53
    }
54
55
    /**
56
     * @param mixed $id
57
     */
58
    public function setId($id): void
59
    {
60
        $this->id = $id;
61
    }
62
63
    public function getPaymentReference(): string
64
    {
65
        return $this->paymentReference;
66
    }
67
68
    public function setPaymentReference(string $paymentReference): void
69
    {
70
        $this->paymentReference = $paymentReference;
71
    }
72
73
    public function getProvider(): string
74
    {
75
        return $this->provider;
76
    }
77
78
    public function setProvider(string $provider): void
79
    {
80
        $this->provider = $provider;
81
    }
82
83
    public function getAmount(): int
84
    {
85
        return $this->amount;
86
    }
87
88
    public function setAmount(int $amount): void
89
    {
90
        $this->amount = $amount;
91
    }
92
93
    public function getCurrency(): string
94
    {
95
        return $this->currency;
96
    }
97
98
    public function setCurrency(string $currency): void
99
    {
100
        $this->currency = $currency;
101
    }
102
103
    public function getCreatedAt(): \DateTimeInterface
104
    {
105
        return $this->createdAt;
106
    }
107
108
    public function setCreatedAt(\DateTimeInterface $createdAt): void
109
    {
110
        $this->createdAt = $createdAt;
111
    }
112
113
    public function isRefunded(): bool
114
    {
115
        return $this->refunded;
116
    }
117
118
    public function setRefunded(bool $refunded): void
119
    {
120
        $this->refunded = $refunded;
121
    }
122
123
    public function isCompleted(): bool
124
    {
125
        return $this->completed;
126
    }
127
128
    public function setCompleted(bool $completed): void
129
    {
130
        $this->completed = $completed;
131
    }
132
133
    public function isChargedBack(): bool
134
    {
135
        return $this->chargedBack;
136
    }
137
138
    public function setChargedBack(bool $chargedBack): void
139
    {
140
        $this->chargedBack = $chargedBack;
141
    }
142
143
    public function getUpdatedAt(): \DateTimeInterface
144
    {
145
        return $this->updatedAt;
146
    }
147
148
    public function setUpdatedAt(\DateTimeInterface $updatedAt): void
149
    {
150
        $this->updatedAt = $updatedAt;
151
    }
152
153
    public function getCustomer(): CustomerInterface
154
    {
155
        return $this->customer;
156
    }
157
158
    public function setCustomer(CustomerInterface $customer): void
159
    {
160
        $this->customer = $customer;
161
    }
162
163
    public function getMoneyAmount(): Money
164
    {
165
        return Money::ofMinor($this->amount, Currency::of($this->currency));
166
    }
167
168
    public function setMoneyAmount(Money $money)
169
    {
170
        $this->amount = $money->getAmount()->getUnscaledValue()->toInt();
171
        $this->currency = $money->getCurrency()->getCurrencyCode();
172
    }
173
174
    public function getSubscription(): ?Subscription
175
    {
176
        return $this->subscription;
177
    }
178
179
    public function setSubscription(?Subscription $subscription): void
180
    {
181
        $this->subscription = $subscription;
182
    }
183
}
184