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

CaptureReservation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 72
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCaptureAmount() 0 4 1
A getCaptureCurrency() 0 4 1
A getCaptureResult() 0 4 1
A getTransactions() 0 4 1
A init() 0 12 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