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

ReconciliationIdentifier::getAmount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Loevgaard\AltaPay\Response\Partial\Transaction;
3
4
use Loevgaard\AltaPay\Exception\ResponseException;
5
use Loevgaard\AltaPay\Response\Partial\PartialResponse;
6
7
class ReconciliationIdentifier extends PartialResponse
8
{
9
    /**
10
     * @var string
11
     */
12
    private $id;
13
14
    /**
15
     * @var float
16
     */
17
    private $amount;
18
19
    /**
20
     * @var int
21
     */
22
    private $amountCurrency;
23
24
    /**
25
     * @var string
26
     */
27
    private $type;
28
29
    /**
30
     * @var \DateTimeImmutable
31
     */
32
    private $date;
33
34
    /**
35
     * @return string
36
     */
37
    public function getId() : string
38
    {
39
        return $this->id;
40
    }
41
42
    /**
43
     * @return float
44
     */
45
    public function getAmount() : float
46
    {
47
        return $this->amount;
48
    }
49
50
    /**
51
     * @return int
52
     */
53
    public function getAmountCurrency() : int
54
    {
55
        return $this->amountCurrency;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getType() : string
62
    {
63
        return $this->type;
64
    }
65
66
    /**
67
     * @return \DateTimeImmutable
68
     */
69
    public function getDate(): \DateTimeImmutable
70
    {
71
        return $this->date;
72
    }
73
74
    protected function init()
75
    {
76
        $this->id = (string)$this->xmlDoc->Id;
77
        $this->amount = (float)$this->xmlDoc->Amount;
78
        $this->amountCurrency = (int)$this->xmlDoc->Amount['currency'];
79
        $this->type = (string)$this->xmlDoc->Type;
80
81
        $this->date = \DateTimeImmutable::createFromFormat(DATE_RFC3339, (string)$this->xmlDoc->Date);
82 View Code Duplication
        if ($this->date === false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
83
            $exception = new ResponseException('The date format is wrong');
84
            $exception->setResponse($this->getOriginalResponse());
85
            throw $exception;
86
        }
87
    }
88
}
89