CustomerInfo   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 106
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrateXml() 0 20 2
A getUserAgent() 0 4 1
A getIpAddress() 0 4 1
A getEmail() 0 4 1
A getUsername() 0 4 1
A getCustomerPhone() 0 4 1
A getOrganisationNumber() 0 4 1
1
<?php
2
namespace Loevgaard\AltaPay\Entity;
3
4
use Loevgaard\AltaPay\Hydrator\HydratableInterface;
5
6
class CustomerInfo implements HydratableInterface
7
{
8
    use CountryOfOriginTrait;
9
    use BillingAddressTrait;
10
    use ShippingAddressTrait;
11
    use RegisteredAddressTrait;
12
13
    /**
14
     * @var string
15
     */
16
    private $userAgent;
17
18
    /**
19
     * @var string
20
     */
21
    private $ipAddress;
22
23
    /**
24
     * @var string
25
     */
26
    private $email;
27
28
    /**
29
     * @var string
30
     */
31
    private $username;
32
33
    /**
34
     * @var string
35
     */
36
    private $customerPhone;
37
38
    /**
39
     * @var string
40
     */
41
    private $organisationNumber;
42
43 33
    public function hydrateXml(\SimpleXMLElement $xml)
44
    {
45 33
        if (!isset($xml->CustomerInfo)) {
46 12
            return;
47
        }
48
49
        /** @var \SimpleXMLElement $customerInfo */
50 21
        $customerInfo = $xml->CustomerInfo;
0 ignored issues
show
Bug introduced by
The property CustomerInfo does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
51
        
52 21
        $this->userAgent = (string)$customerInfo->UserAgent;
53 21
        $this->ipAddress = (string)$customerInfo->IpAddress;
54 21
        $this->email = (string)$customerInfo->Email;
55 21
        $this->username = (string)$customerInfo->Username;
56 21
        $this->customerPhone = (string)$customerInfo->CustomerPhone;
57 21
        $this->organisationNumber = (string)$customerInfo->OrganisationNumber;
58 21
        $this->hydrateCountryOfOrigin($customerInfo);
59 21
        $this->hydrateBillingAddress($customerInfo);
60 21
        $this->hydrateShippingAddress($customerInfo);
61 21
        $this->hydrateRegisteredAddress($customerInfo);
62 21
    }
63
64
    /**
65
     * @return string
66
     */
67 9
    public function getUserAgent() : ?string
68
    {
69 9
        return $this->userAgent;
70
    }
71
72
    /**
73
     * @return string
74
     */
75 9
    public function getIpAddress() : ?string
76
    {
77 9
        return $this->ipAddress;
78
    }
79
80
    /**
81
     * @return string
82
     */
83 9
    public function getEmail() : ?string
84
    {
85 9
        return $this->email;
86
    }
87
88
    /**
89
     * @return string
90
     */
91 9
    public function getUsername() : ?string
92
    {
93 9
        return $this->username;
94
    }
95
96
    /**
97
     * @return string
98
     */
99 9
    public function getCustomerPhone() : ?string
100
    {
101 9
        return $this->customerPhone;
102
    }
103
104
    /**
105
     * @return string
106
     */
107 9
    public function getOrganisationNumber() : ?string
108
    {
109 9
        return $this->organisationNumber;
110
    }
111
}
112