hydrateReconciliationIdentifiers()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 10
cts 10
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 9
nc 3
nop 1
crap 5
1
<?php
2
3
namespace Loevgaard\AltaPay\Entity;
4
5 View Code Duplication
trait ReconciliationIdentifiersTrait
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
6
{
7
    /**
8
     * @var ReconciliationIdentifier[]
9
     */
10
    protected $reconciliationIdentifiers;
11
12
    /**
13
     * @return ReconciliationIdentifier[]
14
     */
15 15
    public function getReconciliationIdentifiers(): array
16
    {
17 15
        $this->initializeReconciliationIdentifiers();
18
19 15
        return $this->reconciliationIdentifiers;
20
    }
21
22
    /**
23
     * @param array $reconciliationIdentifiers
24
     */
25 3
    public function setReconciliationIdentifiers(array $reconciliationIdentifiers)
26
    {
27 3
        $this->reconciliationIdentifiers = $reconciliationIdentifiers;
28 3
    }
29
30
    /**
31
     * @param ReconciliationIdentifier $reconciliationIdentifier
32
     */
33 3
    public function addReconciliationIdentifier(ReconciliationIdentifier $reconciliationIdentifier)
34
    {
35 3
        $this->initializeReconciliationIdentifiers();
36
37 3
        $this->reconciliationIdentifiers[] = $reconciliationIdentifier;
38 3
    }
39
40 33
    public function hydrateReconciliationIdentifiers(\SimpleXMLElement $xml)
41
    {
42 33
        if (!isset($xml->ReconciliationIdentifiers) || !isset($xml->ReconciliationIdentifiers->ReconciliationIdentifier)
43 33
            || empty($xml->ReconciliationIdentifiers->ReconciliationIdentifier)) {
44 12
            return;
45
        }
46
47 21
        $this->initializeReconciliationIdentifiers();
48
49 21
        foreach ($xml->ReconciliationIdentifiers->ReconciliationIdentifier as $reconciliationIdentifierXml) {
50 21
            $reconciliationIdentifier = new ReconciliationIdentifier();
51 21
            $reconciliationIdentifier->hydrateXml($reconciliationIdentifierXml);
52 21
            $this->reconciliationIdentifiers[] = $reconciliationIdentifier;
53
        }
54 21
    }
55
56 30
    private function initializeReconciliationIdentifiers()
57
    {
58 30
        if (is_null($this->reconciliationIdentifiers)) {
59 27
            $this->reconciliationIdentifiers = [];
60
        }
61 30
    }
62
}
63