Completed
Push — master ( 3ee5ff...5084e8 )
by Joachim
12:38
created

RefundCapturedReservation::init()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 16
Code Lines 11

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 11
nc 3
nop 0
1
<?php
2
namespace Loevgaard\AltaPay\Response;
3
4
use Loevgaard\AltaPay\Response\Partial\Transaction;
5
6
class RefundCapturedReservation extends Response
7
{
8
    /**
9
     * @var float
10
     */
11
    protected $refundAmount;
12
13
    /**
14
     * @var int
15
     */
16
    protected $refundCurrency;
17
18
    /**
19
     * @var string
20
     */
21
    protected $result;
22
23
    /**
24
     * @deprecated
25
     * @var string
26
     */
27
    protected $refundResult;
28
29
    /**
30
     * @var Transaction[]
31
     */
32
    protected $transactions;
33
34
    /**
35
     * @return float
36
     */
37
    public function getRefundAmount(): float
38
    {
39
        return $this->refundAmount;
40
    }
41
42
    /**
43
     * @param float $refundAmount
44
     * @return RefundCapturedReservation
45
     */
46
    public function setRefundAmount(float $refundAmount) : self
47
    {
48
        $this->refundAmount = $refundAmount;
49
        return $this;
50
    }
51
52
    /**
53
     * @return int
54
     */
55
    public function getRefundCurrency(): int
56
    {
57
        return $this->refundCurrency;
58
    }
59
60
    /**
61
     * @param int $refundCurrency
62
     * @return RefundCapturedReservation
63
     */
64
    public function setRefundCurrency(int $refundCurrency) : self
65
    {
66
        $this->refundCurrency = $refundCurrency;
67
        return $this;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getResult(): string
74
    {
75
        return $this->result;
76
    }
77
78
    /**
79
     * @param string $result
80
     * @return RefundCapturedReservation
81
     */
82
    public function setResult(string $result) : self
83
    {
84
        $this->result = $result;
85
        return $this;
86
    }
87
88
    /**
89
     * @deprecated
90
     * @return string
91
     */
92
    public function getRefundResult(): string
93
    {
94
        return $this->refundResult;
0 ignored issues
show
Deprecated Code introduced by
The property Loevgaard\AltaPay\Respon...ervation::$refundResult has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
95
    }
96
97
    /**
98
     * @deprecated
99
     * @param string $refundResult
100
     * @return RefundCapturedReservation
101
     */
102
    public function setRefundResult(string $refundResult) : self
103
    {
104
        $this->refundResult = $refundResult;
0 ignored issues
show
Deprecated Code introduced by
The property Loevgaard\AltaPay\Respon...ervation::$refundResult has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
105
        return $this;
106
    }
107
108
    /**
109
     * @return Transaction[]
110
     */
111
    public function getTransactions(): array
112
    {
113
        return $this->transactions;
114
    }
115
116
    /**
117
     * @param Transaction[] $transactions
118
     * @return RefundCapturedReservation
119
     */
120
    public function setTransactions(array $transactions) : self
121
    {
122
        $this->transactions = $transactions;
123
        return $this;
124
    }
125
126
    /**
127
     * @param Transaction $transaction
128
     * @return RefundCapturedReservation
129
     */
130
    public function addTransaction(Transaction $transaction) : self
131
    {
132
        $this->transactions[] = $transaction;
133
        return $this;
134
    }
135
136 View Code Duplication
    protected function init()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
137
    {
138
        $this->transactions = [];
139
        $this->refundAmount = (float)$this->xmlDoc->Body->RefundAmount;
140
        $this->refundCurrency = (int)$this->xmlDoc->Body->RefundCurrency;
141
        $this->result = (string)$this->xmlDoc->Body->Result;
142
        $this->refundResult = (string)$this->xmlDoc->Body->RefundResult;
0 ignored issues
show
Deprecated Code introduced by
The property Loevgaard\AltaPay\Respon...ervation::$refundResult has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
143
144
        if (isset($this->xmlDoc->Body->Transactions) &&
145
            isset($this->xmlDoc->Body->Transactions->Transaction) &&
146
            !empty($this->xmlDoc->Body->Transactions->Transaction)) {
147
            foreach ($this->xmlDoc->Body->Transactions->Transaction as $transactionXml) {
148
                $this->transactions[] = new Transaction($this->getResponse(), $transactionXml);
149
            }
150
        }
151
    }
152
}
153