Completed
Push — master ( 70fc0d...4949f4 )
by Tobias
01:22
created

CountryInfo::getContinentName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Provider\Geonames\Model;
14
15
use Geocoder\Exception\InvalidArgument;
16
use Geocoder\Model\Bounds;
17
18
/**
19
 * @author Srihari Thalla <[email protected]>
20
 */
21
final class CountryInfo
22
{
23
    /**
24
     * @var Bounds|null
25
     */
26
    private $bounds;
27
28
    /**
29
     * @var string|null
30
     */
31
    private $continent;
32
33
    /**
34
     * @var string|null
35
     */
36
    private $capital;
37
38
    /**
39
     * @var array
40
     */
41
    private $languages = [];
42
43
    /**
44
     * @var int|null
45
     */
46
    private $geonameId;
47
48
    /**
49
     * @var string|null
50
     */
51
    private $isoAlpha3;
52
53
    /**
54
     * @var string|null
55
     */
56
    private $fipsCode;
57
58
    /**
59
     * @var int|null
60
     */
61
    private $population;
62
63
    /**
64
     * @var int|null
65
     */
66
    private $isoNumeric;
67
68
    /**
69
     * @var float|null
70
     */
71
    private $areaInSqKm;
72
73
    /**
74
     * @var string|null
75
     */
76
    private $countryCode;
77
78
    /**
79
     * @var string|null
80
     */
81
    private $countryName;
82
83
    /**
84
     * @var string|null
85
     */
86
    private $continentName;
87
88
    /**
89
     * @var string|null
90
     */
91
    private $currencyCode;
92
93
    /**
94
     * @return Bounds|null
95
     */
96 1
    public function getBounds()
97
    {
98 1
        return $this->bounds;
99
    }
100
101
    /**
102
     * @param float $south
103
     * @param float $west
104
     * @param float $north
105
     * @param float $east
106
     *
107
     * @return CountryInfo
108
     */
109 4
    public function setBounds(float $south, float $west, float $north, float $east): self
110
    {
111 4
        $new = clone $this;
112
113
        try {
114 4
            $new->bounds = new Bounds($south, $west, $north, $east);
115
        } catch (InvalidArgument $e) {
116
            $new->bounds = null;
117
        }
118
119 4
        return $new;
120
    }
121
122
    /**
123
     * @return null|string
124
     */
125 1
    public function getContinent()
126
    {
127 1
        return $this->continent;
128
    }
129
130
    /**
131
     * @param null|string $continent
132
     *
133
     * @return CountryInfo
134
     */
135 4
    public function withContinent(string $continent = null): self
136
    {
137 4
        $new = clone $this;
138 4
        $new->continent = $continent;
139
140 4
        return $new;
141
    }
142
143
    /**
144
     * @return null|string
145
     */
146 2
    public function getCapital()
147
    {
148 2
        return $this->capital;
149
    }
150
151
    /**
152
     * @param null|string $capital
153
     *
154
     * @return CountryInfo
155
     */
156 4
    public function withCapital(string $capital = null): self
157
    {
158 4
        $new = clone $this;
159 4
        $new->capital = $capital;
160
161 4
        return $new;
162
    }
163
164
    /**
165
     * @return array
166
     */
167 1
    public function getLanguages(): array
168
    {
169 1
        return $this->languages;
170
    }
171
172
    /**
173
     * @param string $languages
174
     *
175
     * @return CountryInfo
176
     */
177 4
    public function withLanguages(string $languages = ''): self
178
    {
179 4
        $new = clone $this;
180 4
        $new->languages = explode(',', $languages);
181
182 4
        return $new;
183
    }
184
185
    /**
186
     * @return int|null
187
     */
188 1
    public function getGeonameId()
189
    {
190 1
        return $this->geonameId;
191
    }
192
193
    /**
194
     * @param int|null $geonameId
195
     *
196
     * @return CountryInfo
197
     */
198 4
    public function withGeonameId(int $geonameId = null): self
199
    {
200 4
        $new = clone $this;
201 4
        $new->geonameId = null === $geonameId ? null : (int) $geonameId;
202
203 4
        return $new;
204
    }
205
206
    /**
207
     * @return null|string
208
     */
209 1
    public function getIsoAlpha3()
210
    {
211 1
        return $this->isoAlpha3;
212
    }
213
214
    /**
215
     * @param null|string $isoAlpha3
216
     *
217
     * @return CountryInfo
218
     */
219 4
    public function withIsoAlpha3(string $isoAlpha3 = null): self
220
    {
221 4
        $new = clone $this;
222 4
        $new->isoAlpha3 = $isoAlpha3;
223
224 4
        return $new;
225
    }
226
227
    /**
228
     * @return null|string
229
     */
230 1
    public function getFipsCode()
231
    {
232 1
        return $this->fipsCode;
233
    }
234
235
    /**
236
     * @param null|string $fipsCode
237
     *
238
     * @return CountryInfo
239
     */
240 4
    public function withFipsCode(string $fipsCode = null): self
241
    {
242 4
        $new = clone $this;
243 4
        $new->fipsCode = $fipsCode;
244
245 4
        return $new;
246
    }
247
248
    /**
249
     * @return int|null
250
     */
251 1
    public function getPopulation()
252
    {
253 1
        return $this->population;
254
    }
255
256
    /**
257
     * @param int|null $population
258
     *
259
     * @return CountryInfo
260
     */
261 4
    public function withPopulation(string $population = null): self
262
    {
263 4
        $new = clone $this;
264 4
        $new->population = null === $population ? null : (int) $population;
265
266 4
        return $new;
267
    }
268
269
    /**
270
     * @return null|int
271
     */
272 1
    public function getIsoNumeric()
273
    {
274 1
        return $this->isoNumeric;
275
    }
276
277
    /**
278
     * @param string|null $isoNumeric
279
     *
280
     * @return CountryInfo
281
     */
282 4
    public function withIsoNumeric(string $isoNumeric = null): self
283
    {
284 4
        $new = clone $this;
285 4
        $new->isoNumeric = null === $isoNumeric ? null : (int) $isoNumeric;
286
287 4
        return $new;
288
    }
289
290
    /**
291
     * @return null|float
292
     */
293 1
    public function getAreaInSqKm()
294
    {
295 1
        return $this->areaInSqKm;
296
    }
297
298
    /**
299
     * @param string|null $areaInSqKm
300
     *
301
     * @return CountryInfo
302
     */
303 4
    public function withAreaInSqKm(string $areaInSqKm = null): self
304
    {
305 4
        $new = clone $this;
306 4
        $new->areaInSqKm = null === $areaInSqKm ? null : (float) $areaInSqKm;
307
308 4
        return $new;
309
    }
310
311
    /**
312
     * @return null|string
313
     */
314 1
    public function getCountryCode()
315
    {
316 1
        return $this->countryCode;
317
    }
318
319
    /**
320
     * @param string|null $countryCode
321
     *
322
     * @return CountryInfo
323
     */
324 4
    public function withCountryCode(string $countryCode = null): self
325
    {
326 4
        $new = clone $this;
327 4
        $new->countryCode = $countryCode;
328
329 4
        return $new;
330
    }
331
332
    /**
333
     * @return null|string
334
     */
335 1
    public function getCountryName()
336
    {
337 1
        return $this->countryName;
338
    }
339
340
    /**
341
     * @param string|null $countryName
342
     *
343
     * @return CountryInfo
344
     */
345 4
    public function withCountryName(string $countryName = null): self
346
    {
347 4
        $new = clone $this;
348 4
        $new->countryName = $countryName;
349
350 4
        return $new;
351
    }
352
353
    /**
354
     * @return null|string
355
     */
356 1
    public function getContinentName()
357
    {
358 1
        return $this->continentName;
359
    }
360
361
    /**
362
     * @param null|string $continentName
363
     *
364
     * @return CountryInfo
365
     */
366 4
    public function withContinentName(string $continentName = null): self
367
    {
368 4
        $new = clone $this;
369 4
        $new->continentName = $continentName;
370
371 4
        return $new;
372
    }
373
374
    /**
375
     * @return null|string
376
     */
377 1
    public function getCurrencyCode()
378
    {
379 1
        return $this->currencyCode;
380
    }
381
382
    /**
383
     * @param null|string $currencyCode
384
     *
385
     * @return CountryInfo
386
     */
387 4
    public function withCurrencyCode(string $currencyCode = null): self
388
    {
389 4
        $new = clone $this;
390 4
        $new->currencyCode = $currencyCode;
391
392 4
        return $new;
393
    }
394
}
395