Completed
Push — master ( 27b2e7...418156 )
by Christophe
09:36 queued 06:43
created

Artist   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 97
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 97
loc 97
ccs 16
cts 18
cp 0.8889
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getId() 4 4 1
A getName() 4 4 1
A setName() 5 5 1
A getMedias() 4 4 1
A setMedias() 5 5 1
A getSlug() 4 4 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
3
namespace AudioCoreEntity\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Component\Serializer\Annotation\Groups;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
use Gedmo\Timestampable\Traits\TimestampableEntity;
10
11
/**
12
 * Artist
13
 *
14
 * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="name_idx", columns={"name"})})
15
 * @ORM\Entity
16
 */
17 View Code Duplication
class Artist
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...
18
{
19
    use TimestampableEntity;
20
21
    /**
22
     * @var integer
23
     *
24
     * @ORM\Column(name="id", type="integer")
25
     * @ORM\Id
26
     * @ORM\GeneratedValue(strategy="AUTO")
27
     */
28
    private $id;
29
30
    /**
31
     * @var string
32
     *
33
     * @ORM\Column(name="name", type="string", length=200, nullable=false)
34
     * @Groups({"artist-read", "media-read"})
35
     */
36
    private $name;
37
    /**
38
     * @ORM\ManyToMany(targetEntity="\AudioCoreEntity\Entity\Media",mappedBy="artists")
39
     * @Groups({"artist-read"})
40
     **/
41
    private $medias;
42
43
    /**
44
     * @var string
45
     * @Gedmo\Slug(fields={"name"}, unique=true)
46
     * @ORM\Column(type="string", length=128, unique=true)
47
     */
48
    protected $slug;
49
50
    /**
51
     * Artist constructor.
52
     * @param null $name
53
     */
54 2
    public function __construct($name = null)
55
    {
56 2
        $this->setName($name);
57 2
        $this->medias = new ArrayCollection();
58 2
    }
59
60
    /**
61
     * Get id
62
     *
63
     * @return integer 
64
     */
65 1
    public function getId()
66
    {
67 1
        return $this->id;
68
    }
69
70
    /**
71
     * @return string
72
     */
73 1
    public function getName()
74
    {
75 1
        return $this->name;
76
    }
77
78
    /**
79
     * @param string $name
80
     * @return $this
81
     */
82 2
    public function setName($name)
83
    {
84 2
        $this->name = $name;
85 2
        return $this;
86
    }
87
88
    /**
89
     * @return mixed
90
     */
91 1
    public function getMedias()
92
    {
93 1
        return $this->medias;
94
    }
95
96
    /**
97
     * @param mixed $medias
98
     * @return Artist
99
     */
100 1
    public function setMedias($medias)
101
    {
102 1
        $this->medias = $medias;
103 1
        return $this;
104
    }
105
106
    /**
107
     * @return string
108
     */
109
    public function getSlug()
110
    {
111
        return $this->slug;
112
    }
113
}
114