Test Failed
Pull Request — develop (#22)
by Oguzhan
03:49
created

Song   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 129
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
c 1
b 0
f 0
lcom 0
cbo 2
dl 129
loc 129
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getId() 4 4 1
A setId() 5 5 1
A getTitle() 4 4 1
A setTitle() 5 5 1
A getArtist() 4 4 1
A setArtist() 5 5 1
A getDuration() 4 4 1
A setDuration() 5 5 1
A getIsrc() 4 4 1
A setIsrc() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Pbxg33k\MusicInfo\Model;
3
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
7
/**
8
 * Class Song
9
 * @package Pbxg33k\MusicInfo\Model
10
 */
11 View Code Duplication
class Song extends BaseModel
0 ignored issues
show
Duplication introduced by
This class 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...
12
{
13
14
    /**
15
     * @var string
16
     */
17
    protected $id;
18
19
    /**
20
     * @var string
21
     */
22
    protected $title;
23
24
    /**
25
     * @var SongArtist[]
26
     */
27
    protected $artist;
28
29
    /**
30
     * Duration in seconds
31
     *
32
     * @var integer
33
     */
34
    protected $duration;
35
36
    /**
37
     * International Standard Recording Code
38
     *
39
     * @var string
40
     */
41
    protected $isrc;
42
43
    public function __construct()
44
    {
45
        $this->artist = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type array<integer,object<Pbx...Info\Model\SongArtist>> of property $artist.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getId()
52
    {
53
        return $this->id;
54
    }
55
56
    /**
57
     * @param string $id
58
     * @return Song
59
     */
60
    public function setId($id)
61
    {
62
        $this->id = $id;
63
        return $this;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getTitle()
70
    {
71
        return $this->title;
72
    }
73
74
    /**
75
     * @param string $title
76
     * @return Song
77
     */
78
    public function setTitle($title)
79
    {
80
        $this->title = $title;
81
        return $this;
82
    }
83
84
    /**
85
     * @return ArrayCollection
86
     */
87
    public function getArtist()
88
    {
89
        return $this->artist;
90
    }
91
92
    /**
93
     * @param ArrayCollection $artist
94
     * @return Song
95
     */
96
    public function setArtist($artist)
97
    {
98
        $this->artist = $artist;
0 ignored issues
show
Documentation Bug introduced by
It seems like $artist of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type array<integer,object<Pbx...Info\Model\SongArtist>> of property $artist.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
99
        return $this;
100
    }
101
102
    /**
103
     * @return int
104
     */
105
    public function getDuration()
106
    {
107
        return $this->duration;
108
    }
109
110
    /**
111
     * @param int $duration
112
     * @return Song
113
     */
114
    public function setDuration($duration)
115
    {
116
        $this->duration = $duration;
117
        return $this;
118
    }
119
120
    /**
121
     * @return string
122
     */
123
    public function getIsrc()
124
    {
125
        return $this->isrc;
126
    }
127
128
    /**
129
     * @param string $isrc
130
     * @return Song
131
     */
132
    public function setIsrc($isrc)
133
    {
134
        $this->isrc = $isrc;
135
        return $this;
136
    }
137
138
139
}