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

PersonIdentification::createFromXml()   C

Complexity

Conditions 10
Paths 153

Size

Total Lines 48
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 110

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 48
ccs 0
cts 42
cp 0
rs 5.0666
cc 10
eloc 30
nc 153
nop 1
crap 110

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Genkgo\Camt\Decoder\Factory\DTO;
4
5
use DateTimeImmutable;
6
7
class PersonIdentification
8
{
9
    use Behavior\Mapping;
10
11
    public static function createFromXml(SimpleXMLElement $xmlPersonIdentification)
0 ignored issues
show
Unused Code introduced by
The parameter $xmlPersonIdentification is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
12
    {
13
        $xmlPersonIdentification = new DTO\PersonIdentification();
14
15
        $mapping = [
16
            ['setDriversLicenseNumber', 'DrvrsLicNb'],
17
            ['setCustomerNumber', 'CstmrNb'],
18
            ['setSocialSecurityNumber', 'SclSctyNb'],
19
            ['setAlienRegistrationNumber', 'AlnRegnNb'],
20
            ['setPassportNumber', 'PsptNb'],
21
            ['setTaxId', 'TaxIdNb'],
22
            ['setIdCardNumber', 'IdntyCardNb'],
23
            ['setEmployerId', 'MplyrIdNb'],
24
        ];
25
26
        self::map($personIdentification, $xmlPersonIdentification, $mapping);
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
27
28
        if (isset($xmlPersonIdentification->DtAndPlcOfBirth)) {
29
            $xml = $xmlPersonIdentification->DtAndPlcOfBirth;
30
31
            if (isset($xml->BirthDt)) {
32
                $personIdentification->setBirthDate(new DateTimeImmutable((string) $xml->BirthDt));
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
33
            }
34
            if (isset($xml->PrvcOfBirth)) {
35
                $personIdentification->setProvinceOfBirth((string) $xml->PrvcOfBirth);
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
36
            }
37
            if (isset($xml->CityOfBirth)) {
38
                $personIdentification->setCityOfBirth((string) $xml->CityOfBirth);
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
39
            }
40
            if (isset($xml->CtryOfBirth)) {
41
                $personIdentification->setCountryOfBirth((string) $xml->CtryOfBirth);
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
42
            }
43
        }
44
45
        if (isset($xmlPersonIdentification->OthrId)) {
46
            if (isset($xmlPersonIdentification->OthrId->Id)) {
47
                $personIdentification->setOtherIdentification((string) $xmlPersonIdentification->OthrId->Id);
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
48
            }
49
            if (isset($xmlPersonIdentification->OthrId->IdTp)) {
50
                $personIdentification->setOtherIdentificationType((string) $xmlPersonIdentification->OthrId->IdTp);
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
51
            }
52
            if (isset($xmlPersonIdentification->OthrId->SchmeNm)) {
53
                $personIdentification->setOtherIdentificationSc((string) $xmlPersonIdentification->OthrId->IdTp);
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
54
            }
55
        }
56
57
        return $personIdentification;
0 ignored issues
show
Bug introduced by
The variable $personIdentification does not exist. Did you mean $xmlPersonIdentification?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
58
    }
59
}
60