Completed
Push — master ( cd46ad...a80418 )
by
unknown
37:43
created

GeoData   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 138
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 0
dl 0
loc 138
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCountryCode() 0 5 1
A getCountryName() 0 5 1
A getRegion() 0 5 1
A getRegionName() 0 5 1
A getRegionCode() 0 5 1
A getCity() 0 5 1
A getLatitude() 0 5 1
A getLongitude() 0 5 1
A getIp() 0 5 1
A getData() 0 4 1
A setData() 0 4 1
1
<?php
2
3
namespace yiicod\geo;
4
5
6
use yiicod\geo\base\GeoDataInterface;
7
8
/**
9
 * Class GeoData
10
 * Class to make geo-data structure
11
 *
12
 * @package yiicod\geo
13
 *
14
 * @author Dmitry Turchanin
15
 */
16
class GeoData implements GeoDataInterface
17
{
18
    /**
19
     * Data to keep.
20
     *
21
     * @var array
22
     */
23
    private $data = [];
24
25
    /**
26
     * GeoDataInterface constructor.
27
     *
28
     * @param array $data
29
     */
30
    public function __construct(array $data = [])
31
    {
32
        $this->setData($data);
33
    }
34
35
    /**
36
     * Gets country code.
37
     *
38
     * @return null|string
39
     */
40
    public function getCountryCode(): ?string
41
    {
42
        $result = $this->data['countryCode'] ?? null;
43
        return $result;
44
    }
45
46
    /**
47
     * Gets country name
48
     *
49
     * @return null|string
50
     */
51
    public function getCountryName(): ?string
52
    {
53
        $result = $this->data['countryName'] ?? null;
54
        return $result;
55
    }
56
57
    /**
58
     * Gets region
59
     *
60
     * @return null|string
61
     */
62
    public function getRegion(): ?string
63
    {
64
        $result = $this->data['region'] ?? null;
65
        return $result;
66
    }
67
68
    /**
69
     * Gets region name
70
     *
71
     * @return null|string
72
     */
73
    public function getRegionName(): ?string
74
    {
75
        $result = $this->data['regionName'] ?? null;
76
        return $result;
77
    }
78
79
    /**
80
     * Gets region code
81
     *
82
     * @return null|string
83
     */
84
    public function getRegionCode(): ?string
85
    {
86
        $result = $this->data['regionCode'] ?? null;
87
        return $result;
88
    }
89
90
    /**
91
     * Gets city
92
     *
93
     * @return null|string
94
     */
95
    public function getCity(): ?string
96
    {
97
        $result = $this->data['city'] ?? null;
98
        return $result;
99
    }
100
101
    /**
102
     * Gets latitude
103
     *
104
     * @return null|string
105
     */
106
    public function getLatitude(): ?string
107
    {
108
        $result = $this->data['latitude'] ?? null;
109
        return $result;
110
    }
111
112
    /**
113
     * Gets longitude
114
     *
115
     * @return null|string
116
     */
117
    public function getLongitude(): ?string
118
    {
119
        $result = $this->data['longitude'] ?? null;
120
        return $result;
121
    }
122
123
    /**
124
     * Gets IP
125
     *
126
     * @return null|string
127
     */
128
    public function getIp(): string
129
    {
130
        $result = $this->data['ip'] ?? null;
131
        return $result;
132
    }
133
134
    /**
135
     * Gets all data
136
     *
137
     * @return array
138
     */
139
    public function getData(): array
140
    {
141
        return $this->data;
142
    }
143
144
    /**
145
     * Sets all data
146
     *
147
     * @param array $data
148
     */
149
    public function setData(array $data): void
150
    {
151
        $this->data = $data;
152
    }
153
}