Completed
Pull Request — master (#78)
by Alex
02:15
created

City::__construct()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 8.8571
cc 6
eloc 7
nc 32
nop 6
crap 42
1
<?php
2
/**
3
 * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
4
 *
5
 * @license MIT
6
 *
7
 * Please see the LICENSE file distributed with this source code for further
8
 * information regarding copyright and licensing.
9
 *
10
 * Please visit the following links to read about the usage policies and the license of
11
 * OpenWeatherMap before using this class:
12
 *
13
 * @see http://www.OpenWeatherMap.org
14
 * @see http://www.OpenWeatherMap.org/terms
15
 * @see http://openweathermap.org/appid
16
 */
17
18
namespace Cmfcmf\OpenWeatherMap\Util;
19
20
/**
21
 * The city class representing a city object.
22
 */
23
class City
24
{
25
    /**
26
     * @var int The city id.
27
     */
28
    public $id;
29
30
    /**
31
     * @var string The name of the city.
32
     */
33
    public $name;
34
35
    /**
36
     * @var float The longitude of the city.
37
     */
38
    public $lon;
39
40
    /**
41
     * @var float The latitude of the city.
42
     */
43
    public $lat;
44
45
    /**
46
     * @var string The abbreviation of the country the city is located in.
47
     */
48
    public $country;
49
50
    /**
51
     * @var int The city's population
52
     */
53
    public $population;
54
55
    /**
56
     * Create a new city object.
57
     *
58
     * @param int    $id         The city id.
59
     * @param string $name       The name of the city.
60
     * @param float  $lon        The longitude of the city.
61
     * @param float  $lat        The latitude of the city.
62
     * @param string $country    The abbreviation of the country the city is located in
63
     * @param int    $population The city's population.
64
     *
65
     * @internal
66
     */
67
    public function __construct($id, $name = null, $lon = null, $lat = null, $country = null, $population = null)
68
    {
69
        $this->id = (int)$id;
70
        $this->name = isset($name) ? (string)$name : null;
71
        $this->lon = isset($lon) ? (float)$lon : null;
72
        $this->lat = isset($lat) ? (float)$lat : null;
73
        $this->country = isset($country) ? (string)$country : null;
74
        $this->population = isset($population) ? (int)$population : null;
75
    }
76
}
77