Completed
Push — master ( c32e20...5b9784 )
by Alejandro
15s
created

VisitLocation   A

Complexity

Total Complexity 24

Size/Duplication

Total Lines 225
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 26.23%

Importance

Changes 0
Metric Value
dl 0
loc 225
rs 10
c 0
b 0
f 0
ccs 16
cts 61
cp 0.2623
wmc 24
lcom 1
cbo 1

17 Methods

Rating   Name   Duplication   Size   Complexity  
A getCountryCode() 0 4 1
A setCountryCode() 0 5 1
A getRegionName() 0 4 1
A setRegionName() 0 5 1
A getCityName() 0 4 1
A setCityName() 0 5 1
A getLatitude() 0 4 1
A setLatitude() 0 5 1
A getLongitude() 0 4 1
A setLongitude() 0 5 1
A getTimezone() 0 4 1
A setTimezone() 0 5 1
B exchangeArray() 0 24 8
A getArrayCopy() 0 12 1
A jsonSerialize() 0 4 1
A getCountryName() 0 4 1
A setCountryName() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\Core\Entity;
5
6
use Doctrine\ORM\Mapping as ORM;
7
use Shlinkio\Shlink\Common\Entity\AbstractEntity;
8
use Zend\Stdlib\ArraySerializableInterface;
9
10
/**
11
 * Class VisitLocation
12
 * @author
13
 * @link
14
 *
15
 * @ORM\Entity()
16
 * @ORM\Table(name="visit_locations")
17
 */
18
class VisitLocation extends AbstractEntity implements ArraySerializableInterface, \JsonSerializable
19
{
20
    /**
21
     * @var string
22
     * @ORM\Column(nullable=true)
23
     */
24
    protected $countryCode;
25
    /**
26
     * @var string
27
     * @ORM\Column(nullable=true)
28
     */
29
    protected $countryName;
30
    /**
31
     * @var string
32
     * @ORM\Column(nullable=true)
33
     */
34
    protected $regionName;
35
    /**
36
     * @var string
37
     * @ORM\Column(nullable=true)
38
     */
39
    protected $cityName;
40
    /**
41
     * @var string
42
     * @ORM\Column(nullable=true)
43
     */
44
    protected $latitude;
45
    /**
46
     * @var string
47
     * @ORM\Column(nullable=true)
48
     */
49
    protected $longitude;
50
    /**
51
     * @var string
52
     * @ORM\Column(nullable=true)
53
     */
54
    protected $timezone;
55
56
    /**
57
     * @return string
58
     */
59
    public function getCountryCode()
60
    {
61
        return $this->countryCode;
62
    }
63
64
    /**
65
     * @param string $countryCode
66
     * @return $this
67
     */
68
    public function setCountryCode($countryCode)
69
    {
70
        $this->countryCode = $countryCode;
71
        return $this;
72
    }
73
74
    /**
75
     * @return string
76
     */
77 1
    public function getCountryName()
78
    {
79 1
        return $this->countryName;
80
    }
81
82
    /**
83
     * @param string $countryName
84
     * @return $this
85
     */
86 1
    public function setCountryName($countryName)
87
    {
88 1
        $this->countryName = $countryName;
89 1
        return $this;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getRegionName()
96
    {
97
        return $this->regionName;
98
    }
99
100
    /**
101
     * @param string $regionName
102
     * @return $this
103
     */
104
    public function setRegionName($regionName)
105
    {
106
        $this->regionName = $regionName;
107
        return $this;
108
    }
109
110
    /**
111
     * @return string
112
     */
113 3
    public function getCityName()
114
    {
115 3
        return $this->cityName;
116
    }
117
118
    /**
119
     * @param string $cityName
120
     * @return $this
121
     */
122
    public function setCityName($cityName)
123
    {
124
        $this->cityName = $cityName;
125
        return $this;
126
    }
127
128
    /**
129
     * @return string
130
     */
131
    public function getLatitude()
132
    {
133
        return $this->latitude;
134
    }
135
136
    /**
137
     * @param string $latitude
138
     * @return $this
139
     */
140
    public function setLatitude($latitude)
141
    {
142
        $this->latitude = $latitude;
143
        return $this;
144
    }
145
146
    /**
147
     * @return string
148
     */
149
    public function getLongitude()
150
    {
151
        return $this->longitude;
152
    }
153
154
    /**
155
     * @param string $longitude
156
     * @return $this
157
     */
158
    public function setLongitude($longitude)
159
    {
160
        $this->longitude = $longitude;
161
        return $this;
162
    }
163
164
    /**
165
     * @return string
166
     */
167
    public function getTimezone()
168
    {
169
        return $this->timezone;
170
    }
171
172
    /**
173
     * @param string $timezone
174
     * @return $this
175
     */
176
    public function setTimezone($timezone)
177
    {
178
        $this->timezone = $timezone;
179
        return $this;
180
    }
181
182
    /**
183
     * Exchange internal values from provided array
184
     *
185
     * @param  array $array
186
     * @return void
187
     */
188 3
    public function exchangeArray(array $array)
189
    {
190 3
        if (array_key_exists('country_code', $array)) {
191
            $this->setCountryCode($array['country_code']);
192
        }
193 3
        if (array_key_exists('country_name', $array)) {
194
            $this->setCountryName($array['country_name']);
195
        }
196 3
        if (array_key_exists('region_name', $array)) {
197
            $this->setRegionName($array['region_name']);
198
        }
199 3
        if (array_key_exists('city', $array)) {
200
            $this->setCityName($array['city']);
201
        }
202 3
        if (array_key_exists('latitude', $array)) {
203
            $this->setLatitude($array['latitude']);
204
        }
205 3
        if (array_key_exists('longitude', $array)) {
206
            $this->setLongitude($array['longitude']);
207
        }
208 3
        if (array_key_exists('time_zone', $array)) {
209
            $this->setTimezone($array['time_zone']);
210
        }
211 3
    }
212
213
    /**
214
     * Return an array representation of the object
215
     *
216
     * @return array
217
     */
218
    public function getArrayCopy()
219
    {
220
        return [
221
            'countryCode' => $this->countryCode,
222
            'countryName' => $this->countryName,
223
            'regionName' => $this->regionName,
224
            'cityName' => $this->cityName,
225
            'latitude' => $this->latitude,
226
            'longitude' => $this->longitude,
227
            'timezone' => $this->timezone,
228
        ];
229
    }
230
231
    /**
232
     * Specify data which should be serialized to JSON
233
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
234
     * @return mixed data which can be serialized by <b>json_encode</b>,
235
     * which is a value of any type other than a resource.
236
     * @since 5.4.0
237
     */
238
    public function jsonSerialize()
239
    {
240
        return $this->getArrayCopy();
241
    }
242
}
243