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

GetTerminals::init()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 7
Ratio 53.85 %

Importance

Changes 0
Metric Value
dl 7
loc 13
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 8
nc 3
nop 0
1
<?php
2
namespace Loevgaard\AltaPay\Response;
3
4
use Loevgaard\AltaPay\Response\GetTerminals\Terminal;
5
6
class GetTerminals extends Response
7
{
8
    /**
9
     * @var string
10
     */
11
    protected $result;
12
13
    /**
14
     * @var Terminal[]
15
     */
16
    protected $terminals;
17
18
    protected function init()
19
    {
20
        $this->terminals = [];
21
        $this->result = (string)$this->xmlDoc->Body->Result;
22
23 View Code Duplication
        if (isset($this->xmlDoc->Body->Terminals) &&
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...
24
            isset($this->xmlDoc->Body->Terminals->Terminal) &&
25
            !empty($this->xmlDoc->Body->Terminals->Terminal)) {
26
            foreach ($this->xmlDoc->Body->Terminals->Terminal as $terminalXml) {
27
                $this->terminals[] = new Terminal($this->getResponse(), $terminalXml);
28
            }
29
        }
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getResult() : string
36
    {
37
        return $this->result;
38
    }
39
40
    /**
41
     * @return Terminal[]
42
     */
43
    public function getTerminals() : array
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
44
    {
45
        return $this->terminals;
46
    }
47
}
48