Completed
Push — master ( f222c1...bc6c1b )
by Joachim
13:58
created

Terminal::init()   C

Complexity

Conditions 9
Paths 6

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 5.8541
c 0
b 0
f 0
cc 9
eloc 15
nc 6
nop 0
1
<?php
2
namespace Loevgaard\AltaPay\Response\GetTerminals;
3
4
use Loevgaard\AltaPay\Response\GetTerminals\Terminal\Currency;
5
use Loevgaard\AltaPay\Response\GetTerminals\Terminal\Nature;
6
use Loevgaard\AltaPay\Response\PartialResponse;
7
8
class Terminal extends PartialResponse
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $title;
14
15
    /**
16
     * @var string
17
     */
18
    protected $country;
19
20
    /**
21
     * @var Nature[]
22
     */
23
    protected $natures;
24
25
    /**
26
     * @var Currency[]
27
     */
28
    protected $currencies;
29
30
    protected function init()
31
    {
32
        $this->natures = [];
33
        $this->currencies = [];
34
        $this->title = (string)$this->xmlDoc->Title;
35
        $this->country = (string)$this->xmlDoc->Country;
36
37
        if (isset($this->xmlDoc->Natures) &&
38
            isset($this->xmlDoc->Natures->Nature) &&
39
            !empty($this->xmlDoc->Natures->Nature)) {
40
            foreach ($this->xmlDoc->Natures->Nature as $natureXml) {
41
                $this->natures[] = new Nature($this->getOriginalResponse(), $natureXml);
42
            }
43
        }
44
45
        if (isset($this->xmlDoc->Currencies) &&
46
            isset($this->xmlDoc->Currencies->Currency) &&
47
            !empty($this->xmlDoc->Currencies->Currency)) {
48
            foreach ($this->xmlDoc->Currencies->Currency as $currencyXml) {
49
                $this->currencies[] = new Currency($this->getOriginalResponse(), $currencyXml);
50
            }
51
        }
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getTitle() : string
58
    {
59
        return $this->title;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getCountry() : string
66
    {
67
        return $this->country;
68
    }
69
70
    /**
71
     * @return Nature[]
72
     */
73
    public function getNatures() : array
74
    {
75
        return $this->natures;
76
    }
77
78
    /**
79
     * @return Currency[]
80
     */
81
    public function getCurrencies() : array
82
    {
83
        return $this->currencies;
84
    }
85
}
86