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

GetTerminals   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 16.67 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 7
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 7 13 5
A getResult() 0 4 1
A getTerminals() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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