AudioPagePart   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 60
loc 60
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getMedia() 4 4 1
A setMedia() 6 6 1
A __toString() 8 8 2
A getDefaultView() 4 4 1
A getDefaultAdminType() 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 Kunstmaan\MediaPagePartBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Kunstmaan\MediaBundle\Entity\Media;
7
use Kunstmaan\MediaPagePartBundle\Form\AudioPagePartAdminType;
8
use Kunstmaan\PagePartBundle\Entity\AbstractPagePart;
9
10
/**
11
 * AudioPagePart
12
 *
13
 * @ORM\Entity
14
 * @ORM\Table(name="kuma_audio_page_parts")
15
 */
16 View Code Duplication
class AudioPagePart extends AbstractPagePart
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...
17
{
18
    /**
19
     * @ORM\ManyToOne(targetEntity="Kunstmaan\MediaBundle\Entity\Media")
20
     * @ORM\JoinColumn(name="media_id", referencedColumnName="id")
21
     */
22
    protected $media;
23
24
    /**
25
     * Get media
26
     *
27
     * @return Media
28
     */
29 1
    public function getMedia()
30
    {
31 1
        return $this->media;
32
    }
33
34
    /**
35
     * Set media
36
     *
37
     * @param Media $media
38
     *
39
     * @return AudioPagePart
40
     */
41 1
    public function setMedia($media)
42
    {
43 1
        $this->media = $media;
44
45 1
        return $this;
46
    }
47
48
    /**
49
     * @return string
50
     */
51 1
    public function __toString()
52
    {
53 1
        if ($this->getMedia()) {
54 1
            return $this->getMedia()->getUrl();
55
        }
56
57 1
        return '';
58
    }
59
60
    /**
61
     * @return string
62
     */
63 1
    public function getDefaultView()
64
    {
65 1
        return '@KunstmaanMediaPagePart/AudioPagePart/view.html.twig';
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 1
    public function getDefaultAdminType()
72
    {
73 1
        return AudioPagePartAdminType::class;
74
    }
75
}
76