Location   A
last analyzed

Complexity

Total Complexity 23

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 23
lcom 0
cbo 0
dl 0
loc 69
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
F __construct() 0 17 15
A getStreet() 0 4 1
A getStreetNumber() 0 4 1
A getLocality() 0 4 1
A getPostalCode() 0 4 1
A getCountry() 0 4 1
A getLatitude() 0 4 1
A getLongitude() 0 4 1
A getIsVerified() 0 4 1
1
<?php
2
3
namespace SmartyStreets\Location;
4
5
class Location
6
{
7
    private $street;
8
    private $streetNumber;
9
    private $locality;
10
    private $postcode;
11
    private $country = 'Switzerland';
12
    private $latitude;
13
    private $longitude;
14
    private $verified = false;
15
16
    public function __construct($locationArray)
17
    {
18
        $this->verified = (isset($locationArray['analysis']) && $locationArray['analysis']['verification_status'] && $locationArray['analysis']['verification_status'] == 'Verified') ? true : false;
19
20
        if (isset($locationArray['components']) && is_array($locationArray['components'])) {
21
            $this->street = isset($locationArray['components']['thoroughfare']) ? $locationArray['components']['thoroughfare'] : '';
22
            $this->streetNumber = isset($locationArray['components']['premise']) ? $locationArray['components']['premise'] : '';
23
            $this->locality = isset($locationArray['components']['locality']) ? $locationArray['components']['locality'] : '';
24
            $this->postcode = isset($locationArray['components']['postal_code']) ? $locationArray['components']['postal_code'] : '';
25
            $this->country = isset($locationArray['components']['country_iso_3']) ? $locationArray['components']['country_iso_3'] : '';
26
        }
27
28
        if (isset($locationArray['metadata']) && is_array($locationArray['metadata'])) {
29
            $this->latitude = isset($locationArray['metadata']['latitude']) ? $locationArray['metadata']['latitude'] : '';
30
            $this->longitude = isset($locationArray['metadata']['longitude']) ? $locationArray['metadata']['longitude'] : '';
31
        }
32
    }
33
34
    public function getStreet()
35
    {
36
        return $this->street;
37
    }
38
39
    public function getStreetNumber()
40
    {
41
        return $this->streetNumber;
42
    }
43
44
    public function getLocality()
45
    {
46
        return $this->locality;
47
    }
48
49
    public function getPostalCode()
50
    {
51
        return $this->postcode;
52
    }
53
54
    public function getCountry()
55
    {
56
        return $this->country;
57
    }
58
59
    public function getLatitude()
60
    {
61
        return $this->latitude;
62
    }
63
64
    public function getLongitude()
65
    {
66
        return $this->longitude;
67
    }
68
69
    public function getIsVerified()
70
    {
71
        return $this->verified;
72
    }
73
}
74