Label   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 50
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 13 8
1
<?php
2
3
namespace MusicBrainz;
4
5
/**
6
 * Represents a MusicBrainz label object
7
 */
8
class Label
9
{
10
    /**
11
     * @var string
12
     */
13
    public $id;
14
    /**
15
     * @var string
16
     */
17
    public $name;
18
    /**
19
     * @var array
20
     */
21
    public $aliases;
22
    /**
23
     * @var int
24
     */
25
    public $score;
26
    /**
27
     * @var string
28
     */
29
    public $sortName;
30
    /**
31
     * @var string
32
     */
33
    public $country;
34
35
    /**
36
     * @var array
37
     */
38
    private $data;
39
40
    /**
41
     * @param array       $label
42
     * @param MusicBrainz $brainz
43
     */
44
    public function __construct(array $label, MusicBrainz $brainz)
45
    {
46
        $this->data   = $label;
47
        $this->brainz = $brainz;
0 ignored issues
show
Bug introduced by
The property brainz does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
48
49
        $this->id       = isset($label['id']) ? (string)$label['id'] : '';
50
        $this->type     = isset($label['type']) ? (string)$label['type'] : '';
0 ignored issues
show
Bug introduced by
The property type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
51
        $this->score    = isset($label['score']) ? (int)$label['score'] : 0;
52
        $this->sortName = isset($label['sort-name']) ? (string)$label['sort-name'] : '';
53
        $this->name     = isset($label['name']) ? (string)$label['name'] : '';
54
        $this->country  = isset($label['country']) ? (string)$label['country'] : '';
55
        $this->aliases  = isset($label['aliases']) ? $label['aliases'] : array();
56
    }
57
}
58