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

CreditorReferenceInformation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Z38\SwissPayment\RemittanceInformation;
4
5
use Z38\SwissPayment\CreditorReference;
6
7
/**
8
 * CreditorReference
9
 */
10
class CreditorReferenceInformation implements RemittanceInformation
11
{
12
    protected $reference;
13
14
    /**
15
     * @param CreditorReference $reference
16
     */
17
    public function __construct(CreditorReference $reference)
18
    {
19
        $this->reference = $reference;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function asDom(\DOMDocument $doc)
26
    {
27
        $structured = $doc->createElement('Strd');
28
        $referenceInformation = $doc->createElement('CdtrRefInf');
29
30
        $type = $doc->createElement('Tp');
31
        $code = $doc->createElement('CdOrPrtry');
32
        $code->appendChild($doc->createElement('Cd', 'SCOR'));
33
        $type->appendChild($code);
34
        $referenceInformation->appendChild($type);
35
36
        $reference = $doc->createElement('Ref', $this->reference->format());
37
        $referenceInformation->appendChild($reference);
38
39
        $structured->appendChild($referenceInformation);
40
41
        return $structured;
42
    }
43
}
44