FinancialInstitutionAddress::asDom()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
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 Address of the FI
25
     *
26
     * @throws \InvalidArgumentException When the name is invalid.
27
     */
28 3
    public function __construct($name, PostalAddressInterface $address)
29
    {
30 3
        $this->name = Text::assert($name, 70);
31 3
        $this->address = $address;
32 3
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    public function asDom(\DOMDocument $doc)
38
    {
39 2
        $xml = $doc->createElement('FinInstnId');
40 2
        $xml->appendChild(Text::xml($doc, 'Nm', $this->name));
41 2
        $xml->appendChild($this->address->asDom($doc));
42
43 2
        return $xml;
44
    }
45
}
46