Completed
Push — scrutinizer ( 42ac6a...7bc18e )
by z38
02:40
created

FinancialInstitutionAddress::asDom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4286
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Z38\SwissPayment;
4
5
/**
6
 * FinancialInstitutionAddress holds information to identify a FI by name and address
7
 */
8
class FinancialInstitutionAddress implements FinancialInstitutionInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $name;
14
15
    /**
16
     * @var PostalAddressInterface
17
     */
18
    protected $address;
19
20
    /**
21
     * Constructor
22
     *
23
     * @param string $name Name of the FI
24
     * @param PostalAddressInterface Address of the FI
25
     */
26 2
    public function __construct($name, PostalAddressInterface $address)
27
    {
28 2
        $this->name = (string) $name;
29 2
        $this->address = $address;
30 2
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 2
    public function asDom(\DOMDocument $doc)
36
    {
37 2
        $xml = $doc->createElement('FinInstnId');
38 2
        $xml->appendChild($doc->createElement('Nm', $this->name));
39 2
        $xml->appendChild($this->address->asDom($doc));
40
41 2
        return $xml;
42
    }
43
}
44