Completed
Push — master ( ad55a4...c98fe8 )
by Joachim
01:57
created

CaptureReservation::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1
1
<?php
2
namespace Loevgaard\AltaPay\Response;
3
4
use Loevgaard\AltaPay\Entity\ResultTrait;
5
use Loevgaard\AltaPay\Entity\Transaction;
6
use Loevgaard\AltaPay\Entity\TransactionsTrait;
7
8
class CaptureReservation extends Response
9
{
10
    use ResultTrait;
11
    use TransactionsTrait;
12
13
    /**
14
     * @var float
15
     */
16
    protected $captureAmount;
17
18
    /**
19
     * @var int
20
     */
21
    protected $captureCurrency;
22
23
    /**
24
     * @var string
25
     */
26
    protected $captureResult;
27
28
    /**
29
     * @var Transaction[]
30
     */
31
    protected $transactions;
32
33
    /**
34
     * @return float
35
     */
36 3
    public function getCaptureAmount() : float
37
    {
38 3
        return $this->captureAmount;
39
    }
40
41
    /**
42
     * @return int
43
     */
44 3
    public function getCaptureCurrency() : int
45
    {
46 3
        return $this->captureCurrency;
47
    }
48
49
    /**
50
     * @deprecated According to AltaPay documentation this is deprecated,
51
     * @see https://testgateway.altapaysecure.com/merchant/help/Merchant_API#API_captureReservation
52
     * @return string
53
     */
54 3
    public function getCaptureResult() : string
55
    {
56 3
        return $this->captureResult;
57
    }
58
59
    /**
60
     * @return Transaction[]
61
     */
62 3
    public function getTransactions() : array
63
    {
64 3
        return $this->transactions;
65
    }
66
67 6
    protected function init()
68
    {
69
        /** @var \SimpleXMLElement $body */
70 6
        $body = $this->xmlDoc->Body;
0 ignored issues
show
Bug introduced by
The property Body does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
71
72 6
        $this->transactions     = [];
73 6
        $this->captureAmount    = (float)$body->CaptureAmount;
74 6
        $this->captureCurrency  = (int)$body->CaptureCurrency;
75 6
        $this->captureResult    = (string)$body->CaptureResult;
76 6
        $this->hydrateResult($body);
77 6
        $this->hydrateTransactions($body);
78 6
    }
79
}
80