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.
Completed
Push — master ( c67bb4...f85782 )
by Christian
02:29
created

ArtistInfo::getImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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\LastFm\Model;
13
14
final class ArtistInfo
15
{
16
    /**
17
     * @var string
18
     */
19
    private $name;
20
21
    /**
22
     * @var string|null
23
     */
24
    private $mbid;
25
26
    /**
27
     * @var Image[]
28
     */
29
    private $image;
30
31
    /**
32
     * @var string|null
33
     */
34
    private $url;
35
36
    /**
37
     * @var int
38
     */
39
    private $playcount;
40
41
    /**
42
     * @var string|null
43
     */
44
    private $bioSummary;
45
46
    /**
47
     * @var string|null
48
     */
49
    private $bioContent;
50
51
    /**
52
     * @var int
53
     */
54
    private $tagcount;
55
56
    /**
57
     * @var Tag[]
58
     */
59
    private $tags;
60
61
    /**
62
     * ArtistInfo constructor.
63
     *
64
     * @param string      $name
65
     * @param null|string $mbid
66
     * @param Image[]     $image
67
     * @param null|string $url
68
     * @param int         $playcount
69
     * @param null|string $bioSummary
70
     * @param null|string $bioContent
71
     * @param int         $tagcount
72
     * @param Tag[]       $tags
73
     */
74
    public function __construct(
75
        string $name,
76
        ?string $mbid,
77
        array $image,
78
        ?string $url,
79
        int $playcount,
80
        ?string $bioSummary,
81
        ?string $bioContent,
82
        int $tagcount,
83
        array $tags
84
    ) {
85
        $this->name       = $name;
86
        $this->mbid       = $mbid;
87
        $this->image      = $image;
88
        $this->url        = $url;
89
        $this->playcount  = $playcount;
90
        $this->bioSummary = $bioSummary;
91
        $this->bioContent = $bioContent;
92
        $this->tagcount   = $tagcount;
93
        $this->tags       = $tags;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getName(): string
100
    {
101
        return $this->name;
102
    }
103
104
    /**
105
     * @return null|string
106
     */
107
    public function getMbid(): ?string
108
    {
109
        return $this->mbid;
110
    }
111
112
    /**
113
     * @return Image[]
114
     */
115
    public function getImage(): array
116
    {
117
        return $this->image;
118
    }
119
120
    /**
121
     * @return null|string
122
     */
123
    public function getUrl(): ?string
124
    {
125
        return $this->url;
126
    }
127
128
    /**
129
     * @return int
130
     */
131
    public function getPlaycount(): int
132
    {
133
        return $this->playcount;
134
    }
135
136
    /**
137
     * @return null|string
138
     */
139
    public function getBioSummary(): ?string
140
    {
141
        return $this->bioSummary;
142
    }
143
144
    /**
145
     * @return null|string
146
     */
147
    public function getBioContent(): ?string
148
    {
149
        return $this->bioContent;
150
    }
151
152
    /**
153
     * @return int
154
     */
155
    public function getTagcount(): int
156
    {
157
        return $this->tagcount;
158
    }
159
160
    /**
161
     * @return Tag[]
162
     */
163
    public function getTags(): array
164
    {
165
        return $this->tags;
166
    }
167
168
    /**
169
     * @param array $data
170
     *
171
     * @return ArtistInfo
172
     */
173
    public static function fromApi(array $data): self
174
    {
175
        $images = [];
176
        $tags   = [];
177
178
        if (array_key_exists('image', $data)) {
179
            foreach ((array) $data['image'] as $image) {
180
                $images[] = new Image($image['#text']);
181
            }
182
        }
183
184
        if (array_key_exists('tags', $data) && array_key_exists('tag', $data['tags'])) {
185
            foreach ((array) $data['tags']['tag'] as $tag) {
186
                $tags[] = Tag::fromApi($tag);
187
            }
188
        }
189
190
        return new self(
191
            $data['name'],
192
            $data['mbid'] ?? null,
193
            $images,
194
            $data['url'] ?? null,
195
            isset($data['playcount']) ? (int) $data['playcount'] : 0,
196
            $data['bio']['summary'] ?? null,
197
            $data['bio']['content'] ?? null,
198
            isset($data['tagcount']) ? (int) $data['tagcount'] : 0,
199
            $tags
200
        );
201
    }
202
}
203