Completed
Pull Request — master (#26)
by Yann
02:54
created

Recipient::createFromXml()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5.0187

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 19
ccs 10
cts 11
cp 0.9091
rs 8.8571
cc 5
eloc 11
nc 16
nop 1
crap 5.0187
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 16
    public static function createFromXml(SimpleXMLElement $xmlRecipient)
16
    {
17 16
        $recipient = new DTO\Recipient();
18
19 16
        if (isset($xmlRecipient->Nm)) {
20 16
            $recipient->setName((string) $xmlRecipient->Nm);
21
        }
22 16
        if (isset($xmlRecipient->PstlAdr)) {
23 16
            $recipient->setAddress(Address::createFromXml($xmlRecipient->PstlAdr));
24
        }
25 16
        if (isset($xmlRecipient->CtryOfRes)) {
26 16
            $recipient->setCountryOfResidence((string) $xmlRecipient->CtryOfRes);
27
        }
28 16
        if (isset($xmlRecipient->CtctDtls)) {
29
            $recipient->setContactDetails(ContactDetails::createFromXml($xmlRecipient->CtctDtls));
30
        }
31
32 16
        return $recipient;
33
    }
34
}
35