Completed
Pull Request — master (#30)
by
unknown
03:43
created

Survey   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 140
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
c 1
b 0
f 0
lcom 1
cbo 3
dl 140
loc 140
ccs 0
cts 25
cp 0
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getId() 4 4 1
A setType() 6 6 1
A getType() 4 4 1
A setUser() 6 6 1
A getUser() 4 4 1
A setQuestions() 9 9 2
A getQuestions() 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 AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * Survey.
12
 *
13
 * @ORM\Entity(repositoryClass="AppBundle\Repository\SurveyRepository")
14
 */
15 View Code Duplication
class Survey
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...
16
{
17
    use ORMBehaviors\Timestampable\Timestampable;
18
19
    /**
20
     * @var int
21
     *
22
     * @ORM\Column(type="integer")
23
     * @ORM\Id
24
     * @ORM\GeneratedValue(strategy="AUTO")
25
     */
26
    private $id;
27
28
    /**
29
     * @var SurveyType
30
     * @Assert\Type("object")
31
     * @Assert\Valid
32
     * @ORM\ManyToOne(targetEntity="SurveyType", inversedBy="surveys")
33
     */
34
    private $type;
35
36
    /**
37
     * @var User
38
     * @Assert\Type("object")
39
     * @Assert\Valid
40
     * @ORM\ManyToOne(targetEntity="User", inversedBy="surveys")
41
     */
42
    private $user;
43
44
    /**
45
     * @var ArrayCollection[SurveyQuestion]
46
     * @ORM\ManyToMany(targetEntity="SurveyQuestion", mappedBy="surveys")
47
     */
48
    private $questions;
49
50
    /**
51
     * @var ArrayCollection[SurveyAnswer]
52
     * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="survey")
53
     */
54
    private $answers;
55
56
    public function __construct()
57
    {
58
        $this->questions = new ArrayCollection();
59
        $this->answers = new ArrayCollection();
60
    }
61
62
    /**
63
     * Get id.
64
     *
65
     * @return int
66
     */
67
    public function getId()
68
    {
69
        return $this->id;
70
    }
71
72
    /**
73
     * Set type.
74
     *
75
     * @param SurveyType $type
76
     *
77
     * @return Survey
78
     */
79
    public function setType(SurveyType $type)
80
    {
81
        $this->type = $type;
82
83
        return $this;
84
    }
85
86
    /**
87
     * Get type.
88
     *
89
     * @return SurveyType
90
     */
91
    public function getType()
92
    {
93
        return $this->type;
94
    }
95
96
    /**
97
     * Set user.
98
     *
99
     * @param User $user
100
     *
101
     * @return Survey
102
     */
103
    public function setUser(User $user)
104
    {
105
        $this->user = $user;
106
107
        return $this;
108
    }
109
110
    /**
111
     * Get user.
112
     *
113
     * @return User
114
     */
115
    public function getUser()
116
    {
117
        return $this->user;
118
    }
119
120
    /**
121
     * @param SurveyQuestion $question
122
     *
123
     * @return Survey
124
     */
125
    public function setQuestions(SurveyQuestion $question)
126
    {
127
        if (!$this->questions->contains($question)) {
128
            $this->questions->add($question);
129
            $question->setSurveys($this);
130
        }
131
132
        return $this;
133
    }
134
135
    /**
136
     * Get Questions.
137
     *
138
     * @return ArrayCollection
139
     */
140
    public function getQuestions()
141
    {
142
        return $this->questions;
143
    }
144
145
    /**
146
     * Get Questions.
147
     *
148
     * @return ArrayCollection
149
     */
150
    public function getAnswers()
151
    {
152
        return $this->answers;
153
    }
154
}
155