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 ( 547017...c67bb4 )
by Christian
04:20
created

Album   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

7 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 18 4
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
     * Album constructor.
43
     *
44
     * @param null|string $name
45
     * @param Artist|null $artist
46
     * @param null|string $mbid
47
     * @param null|string $url
48
     * @param Image[]     $images
49
     */
50
    public function __construct(?string $name, ?Artist $artist, ?string $mbid, ?string $url, array $images)
51
    {
52
        $this->name   = $name;
53
        $this->artist = $artist;
54
        $this->mbid   = $mbid;
55
        $this->url    = $url;
56
        $this->images = $images;
57
    }
58
59
    /**
60
     * @return null|string
61
     */
62
    public function getName(): ?string
63
    {
64
        return $this->name;
65
    }
66
67
    /**
68
     * @return Artist|null
69
     */
70
    public function getArtist(): ?Artist
71
    {
72
        return $this->artist;
73
    }
74
75
    /**
76
     * @return null|string
77
     */
78
    public function getMbid(): ?string
79
    {
80
        return $this->mbid;
81
    }
82
83
    /**
84
     * @return null|string
85
     */
86
    public function getUrl(): ?string
87
    {
88
        return $this->url;
89
    }
90
91
    /**
92
     * @return Image[]
93
     */
94
    public function getImages(): array
95
    {
96
        return $this->images;
97
    }
98
99
    /**
100
     * @param array $data
101
     *
102
     * @return Album
103
     */
104
    public static function fromApi(array $data): self
105
    {
106
        $images = [];
107
108
        if (array_key_exists('image', $data)) {
109
            foreach ((array) $data['image'] as $image) {
110
                $images[] = new Image($image['#text']);
111
            }
112
        }
113
114
        return new self(
115
            $data['name'],
116
            $data['artist'] ? Artist::fromApi($data['artist']) : null,
117
            $data['mbid'] ?? null,
118
            $data['url'] ?? null,
119
            $images
120
        );
121
    }
122
}
123