ReleaseGroup::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace MusicBrainz;
4
5
/**
6
 * Represents a MusicBrainz release group
7
 *
8
 */
9
class ReleaseGroup
10
{
11
    /**
12
     * @var string
13
     */
14
    public $id;
15
    /**
16
     * @var array
17
     */
18
    private $data;
19
    /**
20
     * @var MusicBrainz
21
     */
22
    private $brainz;
23
    /**
24
     * @var Release[]
25
     */
26
    private $releases = array();
27
28
    /**
29
     * @param array       $releaseGroup
30
     * @param MusicBrainz $brainz
31
     */
32 View Code Duplication
    public function __construct(array $releaseGroup, MusicBrainz $brainz)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        $this->data   = $releaseGroup;
35
        $this->brainz = $brainz;
36
37
        $this->id = isset($releaseGroup['id']) ? (string)$releaseGroup['id'] : '';
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getId()
44
    {
45
        return $this->id;
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getTitle()
52
    {
53
        return $this->data['title'];
54
    }
55
56
    /**
57
     * @return mixed
58
     */
59
    public function getScore()
60
    {
61
        return $this->data['score'];
62
    }
63
64
    /**
65
     * @return Release[]
66
     */
67
    public function getReleases()
68
    {
69
        if (!empty($this->releases)) {
70
            return $this->releases;
71
        }
72
73
        foreach ($this->data['releases'] as $release) {
74
            array_push($this->releases, new Release($release, $this->brainz));
75
        }
76
77
        return $this->releases;
78
    }
79
}
80