Passed
Push — main ( 1a48f2...b37496 )
by Iain
05:11
created

Refund::getMoneyAmount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
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 Humbly Arrogant Software Limited 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
use Parthenon\Billing\Enum\RefundStatus;
20
21
class Refund
22
{
23
    private $id;
24
25
    private CustomerInterface $customer;
26
27
    private Payment $payment;
28
29
    private int $amount;
30
31
    private string $currency;
32
33
    private RefundStatus $status;
34
35
    private string $externalReference;
36
37
    private ?BillingAdminInterface $billingAdmin = null;
38
39
    private ?string $reason = null;
40
41
    private \DateTimeInterface $createdAt;
42
43
    /**
44
     * @return mixed
45
     */
46
    public function getId()
47
    {
48
        return $this->id;
49
    }
50
51
    /**
52
     * @param mixed $id
53
     */
54
    public function setId($id): void
55
    {
56
        $this->id = $id;
57
    }
58
59
    public function getCustomer(): CustomerInterface
60
    {
61
        return $this->customer;
62
    }
63
64
    public function setCustomer(CustomerInterface $customer): void
65
    {
66
        $this->customer = $customer;
67
    }
68
69
    public function getPayment(): Payment
70
    {
71
        return $this->payment;
72
    }
73
74
    public function setPayment(Payment $payment): void
75
    {
76
        $this->payment = $payment;
77
    }
78
79
    public function getAmount(): int
80
    {
81
        return $this->amount;
82
    }
83
84
    public function setAmount(int $amount): void
85
    {
86
        $this->amount = $amount;
87
    }
88
89
    public function getAsMoney(): Money
90
    {
91
        return Money::ofMinor($this->amount, Currency::of(strtoupper($this->currency)));
92
    }
93
94
    public function getCurrency(): string
95
    {
96
        return strtoupper($this->currency);
97
    }
98
99
    public function setCurrency(string $currency): void
100
    {
101
        $this->currency = $currency;
102
    }
103
104
    public function getStatus(): RefundStatus
105
    {
106
        return $this->status;
107
    }
108
109
    public function setStatus(RefundStatus $status): void
110
    {
111
        $this->status = $status;
112
    }
113
114
    public function getBillingAdmin(): ?BillingAdminInterface
115
    {
116
        return $this->billingAdmin;
117
    }
118
119
    public function setBillingAdmin(?BillingAdminInterface $billingAdmin): void
120
    {
121
        $this->billingAdmin = $billingAdmin;
122
    }
123
124
    public function getReason(): ?string
125
    {
126
        return $this->reason;
127
    }
128
129
    public function setReason(?string $reason): void
130
    {
131
        $this->reason = $reason;
132
    }
133
134
    public function getCreatedAt(): \DateTimeInterface
135
    {
136
        return $this->createdAt;
137
    }
138
139
    public function setCreatedAt(\DateTimeInterface $createdAt): void
140
    {
141
        $this->createdAt = $createdAt;
142
    }
143
144
    public function getExternalReference(): string
145
    {
146
        return $this->externalReference;
147
    }
148
149
    public function setExternalReference(string $externalReference): void
150
    {
151
        $this->externalReference = $externalReference;
152
    }
153
154
    public function getMoneyAmount(): Money
155
    {
156
        return Money::ofMinor($this->amount, Currency::of($this->getCurrency()));
157
    }
158
}
159