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

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