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

Recipient   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 7
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 32
ccs 13
cts 14
cp 0.9286
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C createFromXml() 0 24 7
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