Recipient::createFromXml()   B
last analyzed

Complexity

Conditions 7
Paths 48

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 7.0178

Importance

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