Completed
Push — wip ( 681ec1 )
by z38
02:37
created

QRReferenceInformation::asDom()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2.0219

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 14
cts 17
cp 0.8235
rs 8.8571
c 0
b 0
f 0
cc 2
eloc 16
nc 2
nop 1
crap 2.0219
1
<?php
2
3
namespace Z38\SwissPayment\RemittanceInformation;
4
5
use Z38\SwissPayment\QRReference;
6
7
/**
8
 * QRReferenceInformation
9
 */
10
class QRReferenceInformation implements RemittanceInformation
11
{
12
    /**
13
     * @var QRReference
14
     */
15
    protected $reference;
16
17
    /**
18
     * @var string|null
19
     */
20
    protected $additionalInformation;
21
22
    /**
23
     * @param QRReference $reference
24
     * @param string|null $additionalInformation
25
     */
26 2
    public function __construct(QRReference $reference, $additionalInformation)
0 ignored issues
show
Unused Code introduced by
The parameter $additionalInformation is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28 2
        $this->reference = $reference;
29 2
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 2
    public function asDom(\DOMDocument $doc)
35
    {
36 2
        $structured = $doc->createElement('Strd');
37
38 2
        $referenceInformation = $doc->createElement('CdtrRefInf');
39 2
        $structured->appendChild($referenceInformation);
40
41 2
        $type = $doc->createElement('Tp');
42 2
        $code = $doc->createElement('CdOrPrtry');
43 2
        $code->appendChild($doc->createElement('Prtry', 'QRR'));
44 2
        $type->appendChild($code);
45 2
        $referenceInformation->appendChild($type);
46
47 2
        $reference = $doc->createElement('Ref', $this->reference->format());
48 2
        $referenceInformation->appendChild($reference);
49
50 2
        $structured->appendChild($referenceInformation);
51
52 2
        if (strlen($this->additionalInformation)) {
53
            $additionalInformation = $doc->createElement('AddtlRmtInf', $this->additionalInformation);
54
            $structured->appendChild($additionalInformation);
55
        }
56
57 2
        return $structured;
58
    }
59
}
60