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.

City   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 112
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A getId() 0 4 1
A getName() 0 4 1
A getState() 0 4 1
A getStateCode() 0 4 1
A getCounty() 0 4 1
A getCountry() 0 4 1
A getGeo() 0 4 1
A fromApi() 0 22 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\SetlistFm\Model;
13
14
final class City
15
{
16
    /**
17
     * @var int
18
     */
19
    private $id;
20
21
    /**
22
     * @var string
23
     */
24
    private $name;
25
26
    /**
27
     * @var string|null
28
     */
29
    private $state;
30
31
    /**
32
     * @var string|null
33
     */
34
    private $stateCode;
35
36
    /**
37
     * @var Country|null
38
     */
39
    private $country;
40
41
    /**
42
     * @var Geo|null
43
     */
44
    private $geo;
45
46
    public function __construct(
47
        int $id,
48
        string $name,
49
        ?string $state,
50
        ?string $stateCode,
51
        ?Country $county,
52
        ?Geo $geo
53
    ) {
54
        $this->id        = $id;
55
        $this->name      = $name;
56
        $this->state     = $state;
57
        $this->stateCode = $stateCode;
58
        $this->country   = $county;
59
        $this->geo       = $geo;
60
    }
61
62
    public function getId(): int
63
    {
64
        return $this->id;
65
    }
66
67
    public function getName(): string
68
    {
69
        return $this->name;
70
    }
71
72
    public function getState(): ?string
73
    {
74
        return $this->state;
75
    }
76
77
    public function getStateCode(): ?string
78
    {
79
        return $this->stateCode;
80
    }
81
82
    /**
83
     * @deprecated use getCountry instead
84
     */
85
    public function getCounty(): ?Country
86
    {
87
        return $this->getCountry();
88
    }
89
90
    public function getCountry(): ?Country
91
    {
92
        return $this->country;
93
    }
94
95
    public function getGeo(): ?Geo
96
    {
97
        return $this->geo;
98
    }
99
100
    /**
101
     * @return City
102
     */
103
    public static function fromApi(array $data): self
104
    {
105
        $geo     = null;
106
        $country = null;
107
108
        if ($data['coords']) {
109
            $geo = Geo::fromApi($data['coords']);
110
        }
111
112
        if ($data['country']) {
113
            $country = Country::fromApi($data['country']);
114
        }
115
116
        return new self(
117
            (int) $data['id'],
118
            $data['name'],
119
            $data['state'] ?? null,
120
            $data['stateCode'] ?? null,
121
            $country,
122
            $geo
123
        );
124
    }
125
}
126