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

SurveyQuestion   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 143
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 143
loc 143
ccs 0
cts 25
cp 0
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setSurveys() 9 9 2
A getSurveys() 4 4 1
A __construct() 5 5 1
A getId() 4 4 1
A setTitle() 6 6 1
A getTitle() 4 4 1
A setSurveyType() 6 6 1
A getSurveyType() 4 4 1
A getAnswers() 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
 * SurveyQuestion.
12
 *
13
 * @ORM\Entity(repositoryClass="AppBundle\Repository\SurveyQuestionRepository")
14
 */
15 View Code Duplication
class SurveyQuestion
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 string
30
     * @Assert\NotBlank()
31
     * @Assert\Type("string")
32
     * @Assert\Length(
33
     *      max = 500
34
     * )
35
     * @ORM\Column(name="body", type="text")
36
     */
37
    private $title;
38
39
    /**
40
     * @var SurveyType
41
     * @Assert\Type("object")
42
     * @Assert\Valid
43
     * @ORM\ManyToOne(targetEntity="SurveyType", inversedBy="questions")
44
     */
45
    private $surveyType;
46
47
    /**
48
     * @var ArrayCollection[Survey]
49
     * @ORM\ManyToMany(targetEntity="Survey", inversedBy="questions")
50
     */
51
    private $surveys;
52
53
    /**
54
     * @var ArrayCollection[SurveyAnswer]
55
     * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="question")
56
     */
57
    private $answers;
58
59
    public function __construct()
60
    {
61
        $this->surveys = new ArrayCollection();
62
        $this->answers = new ArrayCollection();
63
    }
64
65
    /**
66
     * Get id.
67
     *
68
     * @return int
69
     */
70
    public function getId()
71
    {
72
        return $this->id;
73
    }
74
75
    /**
76
     * Set title.
77
     *
78
     * @param string $title
79
     *
80
     * @return SurveyQuestion
81
     */
82
    public function setTitle($title)
83
    {
84
        $this->title = $title;
85
86
        return $this;
87
    }
88
89
    /**
90
     * Get title.
91
     *
92
     * @return string
93
     */
94
    public function getTitle()
95
    {
96
        return $this->title;
97
    }
98
99
    /**
100
     * Set type.
101
     *
102
     * @param SurveyType $type
103
     *
104
     * @return SurveyQuestion
105
     */
106
    public function setSurveyType(SurveyType $type)
107
    {
108
        $this->surveyType = $type;
109
110
        return $this;
111
    }
112
113
    /**
114
     * Get type.
115
     *
116
     * @return SurveyType
117
     */
118
    public function getSurveyType()
119
    {
120
        return $this->surveyType;
121
    }
122
123
    /**
124
     * @param Survey $survey
125
     *
126
     * @return SurveyQuestion
127
     */
128
    public function setSurveys(Survey $survey)
129
    {
130
        if (!$this->surveys->contains($survey)) {
131
            $this->surveys->add($survey);
132
            $survey->setQuestions($this);
133
        }
134
135
        return $this;
136
    }
137
138
    /**
139
     * Get Surveys.
140
     *
141
     * @return ArrayCollection
142
     */
143
    public function getSurveys()
144
    {
145
        return $this->surveys;
146
    }
147
148
    /**
149
     * Get Answers.
150
     *
151
     * @return ArrayCollection
152
     */
153
    public function getAnswers()
154
    {
155
        return $this->answers;
156
    }
157
}
158