Completed
Pull Request — master (#32)
by
unknown
04:50
created

Recipient   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 87.5%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 8
c 2
b 0
f 2
lcom 0
cbo 5
dl 0
loc 35
ccs 14
cts 16
cp 0.875
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C createFromXml() 0 27 8
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 18
    public static function createFromXml(SimpleXMLElement $xmlRecipient)
16
    {
17 18
        $recipient = new DTO\Recipient();
18
19 18
        if (isset($xmlRecipient->Nm)) {
20 18
            $recipient->setName((string) $xmlRecipient->Nm);
21
        }
22 18
        if (isset($xmlRecipient->PstlAdr)) {
23 18
            $recipient->setAddress(Address::createFromXml($xmlRecipient->PstlAdr));
24
        }
25 18
        if (isset($xmlRecipient->CtryOfRes)) {
26 18
            $recipient->setCountryOfResidence((string) $xmlRecipient->CtryOfRes);
27
        }
28 18
        if (isset($xmlRecipient->CtctDtls)) {
29
            $recipient->setContactDetails(ContactDetails::createFromXml($xmlRecipient->CtctDtls));
30
        }
31 18
        if (isset($xmlRecipient->Id)) {
32 18
            if (isset($xmlRecipient->Id->OrgId)) {
33 18
                $recipient->setIdentification(OrganisationIdentification::createFromXml($xmlRecipient->Id->OrgId));
34
            }
35 18
            if (isset($xmlRecipient->Id->PrvtId)) {
36
                $recipient->setIdentification(PersonIdentification::createFromXml($xmlRecipient->Id->PrvtId));
37
            }
38
        }
39
40 18
        return $recipient;
41
    }
42
}
43