Completed
Pull Request — master (#105)
by Mikołaj
04:26 queued 01:11
created

VisitLocation::setLatitude()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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