Completed
Pull Request — master (#27)
by Yann
02:57
created

Recipient   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 82.61%

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