Completed
Push — master ( a4151f...f7c7ac )
by Frederik
03:04
created

Recipient::createFromXml()   C

Complexity

Conditions 7
Paths 48

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 7.0178

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 24
ccs 13
cts 14
cp 0.9286
rs 6.7272
cc 7
eloc 14
nc 48
nop 1
crap 7.0178
1
<?php
2
3
namespace Genkgo\Camt\Decoder\Factory\DTO;
4
5
use SimpleXMLElement;
6
use Genkgo\Camt\DTO;
7
8
class Recipient
9
{
10
    /**
11
     * @param SimpleXMLElement $xmlRecipient
12
     *
13
     * @return DTO\Recipient
14
     */
15 21
    public static function createFromXml(SimpleXMLElement $xmlRecipient)
16
    {
17 21
        $recipient = new DTO\Recipient();
18
19 21
        if (isset($xmlRecipient->Nm)) {
20 21
            $recipient->setName((string) $xmlRecipient->Nm);
21
        }
22 21
        if (isset($xmlRecipient->PstlAdr)) {
23 21
            $recipient->setAddress(Address::createFromXml($xmlRecipient->PstlAdr));
24
        }
25 21
        if (isset($xmlRecipient->CtryOfRes)) {
26 21
            $recipient->setCountryOfResidence((string) $xmlRecipient->CtryOfRes);
27
        }
28 21
        if (isset($xmlRecipient->CtctDtls)) {
29
            $recipient->setContactDetails(ContactDetails::createFromXml($xmlRecipient->CtctDtls));
30
        }
31 21
        if (isset($xmlRecipient->Id)) {
32 21
            if (isset($xmlRecipient->Id->OrgId)) {
33 21
                $recipient->setIdentification(OrganisationIdentification::createFromXml($xmlRecipient->Id->OrgId));
34
            }
35
        }
36
37 21
        return $recipient;
38
    }
39
}
40