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.

Album   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getName() 0 4 1
A getArtist() 0 4 1
A getMbid() 0 4 1
A getUrl() 0 4 1
A getImages() 0 4 1
A fromApi() 0 12 2
A createImagesFromApi() 0 12 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\LastFm\Model;
13
14
final class Album
15
{
16
    /**
17
     * @var string|null
18
     */
19
    private $name;
20
21
    /**
22
     * @var Artist|null
23
     */
24
    private $artist;
25
26
    /**
27
     * @var string|null
28
     */
29
    private $mbid;
30
31
    /**
32
     * @var string|null
33
     */
34
    private $url;
35
36
    /**
37
     * @var Image[]
38
     */
39
    private $images;
40
41
    /**
42
     * @param Image[] $images
43
     */
44
    public function __construct(?string $name, ?Artist $artist, ?string $mbid, ?string $url, array $images)
45
    {
46
        $this->name   = $name;
47
        $this->artist = $artist;
48
        $this->mbid   = $mbid;
49
        $this->url    = $url;
50
        $this->images = $images;
51
    }
52
53
    public function getName(): ?string
54
    {
55
        return $this->name;
56
    }
57
58
    public function getArtist(): ?Artist
59
    {
60
        return $this->artist;
61
    }
62
63
    public function getMbid(): ?string
64
    {
65
        return $this->mbid;
66
    }
67
68
    public function getUrl(): ?string
69
    {
70
        return $this->url;
71
    }
72
73
    /**
74
     * @return Image[]
75
     */
76
    public function getImages(): array
77
    {
78
        return $this->images;
79
    }
80
81
    /**
82
     * @return Album
83
     */
84
    public static function fromApi(array $data): self
85
    {
86
        $images = self::createImagesFromApi($data);
87
88
        return new self(
89
            $data['name'],
90
            $data['artist'] ? Artist::fromApi($data['artist']) : null,
91
            $data['mbid'] ?? null,
92
            $data['url'] ?? null,
93
            $images
94
        );
95
    }
96
97
    private static function createImagesFromApi(array $data): array
98
    {
99
        $images = [];
100
101
        if (\array_key_exists('image', $data)) {
102
            foreach ((array) $data['image'] as $image) {
103
                $images[] = new Image($image['#text']);
104
            }
105
        }
106
107
        return $images;
108
    }
109
}
110