GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CountryInfo::withPopulation()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 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
    public function getBounds()
97
    {
98
        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
    public function setBounds(float $south, float $west, float $north, float $east): self
110
    {
111
        $new = clone $this;
112
113
        try {
114
            $new->bounds = new Bounds($south, $west, $north, $east);
115
        } catch (InvalidArgument $e) {
116
            $new->bounds = null;
117
        }
118
119
        return $new;
120
    }
121
122
    /**
123
     * @return null|string
124
     */
125
    public function getContinent()
126
    {
127
        return $this->continent;
128
    }
129
130
    /**
131
     * @param null|string $continent
132
     *
133
     * @return CountryInfo
134
     */
135
    public function withContinent(string $continent = null): self
136
    {
137
        $new = clone $this;
138
        $new->continent = $continent;
139
140
        return $new;
141
    }
142
143
    /**
144
     * @return null|string
145
     */
146
    public function getCapital()
147
    {
148
        return $this->capital;
149
    }
150
151
    /**
152
     * @param null|string $capital
153
     *
154
     * @return CountryInfo
155
     */
156
    public function withCapital(string $capital = null): self
157
    {
158
        $new = clone $this;
159
        $new->capital = $capital;
160
161
        return $new;
162
    }
163
164
    /**
165
     * @return array
166
     */
167
    public function getLanguages(): array
168
    {
169
        return $this->languages;
170
    }
171
172
    /**
173
     * @param string $languages
174
     *
175
     * @return CountryInfo
176
     */
177
    public function withLanguages(string $languages = ''): self
178
    {
179
        $new = clone $this;
180
        $new->languages = explode(',', $languages);
181
182
        return $new;
183
    }
184
185
    /**
186
     * @return int|null
187
     */
188
    public function getGeonameId()
189
    {
190
        return $this->geonameId;
191
    }
192
193
    /**
194
     * @param int|null $geonameId
195
     *
196
     * @return CountryInfo
197
     */
198
    public function withGeonameId(int $geonameId = null): self
199
    {
200
        $new = clone $this;
201
        $new->geonameId = null === $geonameId ? null : (int) $geonameId;
202
203
        return $new;
204
    }
205
206
    /**
207
     * @return null|string
208
     */
209
    public function getIsoAlpha3()
210
    {
211
        return $this->isoAlpha3;
212
    }
213
214
    /**
215
     * @param null|string $isoAlpha3
216
     *
217
     * @return CountryInfo
218
     */
219
    public function withIsoAlpha3(string $isoAlpha3 = null): self
220
    {
221
        $new = clone $this;
222
        $new->isoAlpha3 = $isoAlpha3;
223
224
        return $new;
225
    }
226
227
    /**
228
     * @return null|string
229
     */
230
    public function getFipsCode()
231
    {
232
        return $this->fipsCode;
233
    }
234
235
    /**
236
     * @param null|string $fipsCode
237
     *
238
     * @return CountryInfo
239
     */
240
    public function withFipsCode(string $fipsCode = null): self
241
    {
242
        $new = clone $this;
243
        $new->fipsCode = $fipsCode;
244
245
        return $new;
246
    }
247
248
    /**
249
     * @return int|null
250
     */
251
    public function getPopulation()
252
    {
253
        return $this->population;
254
    }
255
256
    /**
257
     * @param int|null $population
0 ignored issues
show
Documentation introduced by
Should the type for parameter $population not be null|string?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
258
     *
259
     * @return CountryInfo
260
     */
261
    public function withPopulation(string $population = null): self
262
    {
263
        $new = clone $this;
264
        $new->population = null === $population ? null : (int) $population;
265
266
        return $new;
267
    }
268
269
    /**
270
     * @return null|int
271
     */
272
    public function getIsoNumeric()
273
    {
274
        return $this->isoNumeric;
275
    }
276
277
    /**
278
     * @param string|null $isoNumeric
279
     *
280
     * @return CountryInfo
281
     */
282
    public function withIsoNumeric(string $isoNumeric = null): self
283
    {
284
        $new = clone $this;
285
        $new->isoNumeric = null === $isoNumeric ? null : (int) $isoNumeric;
286
287
        return $new;
288
    }
289
290
    /**
291
     * @return null|float
292
     */
293
    public function getAreaInSqKm()
294
    {
295
        return $this->areaInSqKm;
296
    }
297
298
    /**
299
     * @param string|null $areaInSqKm
300
     *
301
     * @return CountryInfo
302
     */
303
    public function withAreaInSqKm(string $areaInSqKm = null): self
304
    {
305
        $new = clone $this;
306
        $new->areaInSqKm = null === $areaInSqKm ? null : (float) $areaInSqKm;
307
308
        return $new;
309
    }
310
311
    /**
312
     * @return null|string
313
     */
314
    public function getCountryCode()
315
    {
316
        return $this->countryCode;
317
    }
318
319
    /**
320
     * @param string|null $countryCode
321
     *
322
     * @return CountryInfo
323
     */
324
    public function withCountryCode(string $countryCode = null): self
325
    {
326
        $new = clone $this;
327
        $new->countryCode = $countryCode;
328
329
        return $new;
330
    }
331
332
    /**
333
     * @return null|string
334
     */
335
    public function getCountryName()
336
    {
337
        return $this->countryName;
338
    }
339
340
    /**
341
     * @param string|null $countryName
342
     *
343
     * @return CountryInfo
344
     */
345
    public function withCountryName(string $countryName = null): self
346
    {
347
        $new = clone $this;
348
        $new->countryName = $countryName;
349
350
        return $new;
351
    }
352
353
    /**
354
     * @return null|string
355
     */
356
    public function getContinentName()
357
    {
358
        return $this->continentName;
359
    }
360
361
    /**
362
     * @param null|string $continentName
363
     *
364
     * @return CountryInfo
365
     */
366
    public function withContinentName(string $continentName = null): self
367
    {
368
        $new = clone $this;
369
        $new->continentName = $continentName;
370
371
        return $new;
372
    }
373
374
    /**
375
     * @return null|string
376
     */
377
    public function getCurrencyCode()
378
    {
379
        return $this->currencyCode;
380
    }
381
382
    /**
383
     * @param null|string $currencyCode
384
     *
385
     * @return CountryInfo
386
     */
387
    public function withCurrencyCode(string $currencyCode = null): self
388
    {
389
        $new = clone $this;
390
        $new->currencyCode = $currencyCode;
391
392
        return $new;
393
    }
394
}
395