Completed
Pull Request — dev (#18)
by
unknown
26:42
created

SurveyQuestion::getAnswer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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 Survey
49
     * @Assert\Type("object")
50
     * @Assert\Valid
51
     * @ORM\ManyToMany(targetEntity="Survey", inversedBy="questions")
52
     */
53
    private $surveys;
54
55
    /**
56
     * @var ArrayCollection|SurveyAnswer[]
57
     * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="question")
58
     */
59
    private $answers;
60
61
    public function __construct()
62
    {
63
        $this->surveys = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<AppBundle\Entity\Survey> of property $surveys.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
64
        $this->answers = new ArrayCollection();
65
    }
66
67
    /**
68
     * Get id.
69
     *
70
     * @return int
71
     */
72
    public function getId()
73
    {
74
        return $this->id;
75
    }
76
77
    /**
78
     * Set title.
79
     *
80
     * @param string $title
81
     *
82
     * @return SurveyQuestion
83
     */
84
    public function setTitle($title)
85
    {
86
        $this->title = $title;
87
88
        return $this;
89
    }
90
91
    /**
92
     * Get title.
93
     *
94
     * @return string
95
     */
96
    public function getTitle()
97
    {
98
        return $this->title;
99
    }
100
101
    /**
102
     * Set type.
103
     *
104
     * @param SurveyType $type
105
     *
106
     * @return SurveyQuestion
107
     */
108
    public function setSurveyType(SurveyType $type)
109
    {
110
        $this->surveyType = $type;
111
112
        return $this;
113
    }
114
115
    /**
116
     * Get type.
117
     *
118
     * @return SurveyType
119
     */
120
    public function getSurveyType()
121
    {
122
        return $this->surveyType;
123
    }
124
125
    /**
126
     * @param Survey $survey
127
     *
128
     * @return SurveyQuestion
129
     */
130
    public function addSurvey(Survey $survey)
131
    {
132
        if (!$this->surveys->contains($survey)) {
0 ignored issues
show
Bug introduced by
The method contains() does not seem to exist on object<AppBundle\Entity\Survey>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
133
            $this->surveys->add($survey);
0 ignored issues
show
Bug introduced by
The method add() does not seem to exist on object<AppBundle\Entity\Survey>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
134
            $survey->addQuestion($this);
135
        }
136
137
        return $this;
138
    }
139
140
    /**
141
     * Get Surveys.
142
     *
143
     * @return ArrayCollection
144
     */
145
    public function getSurveys()
146
    {
147
        return $this->surveys;
148
    }
149
150
    /**
151
     * Get Answers.
152
     *
153
     * @return ArrayCollection
154
     */
155
    public function getAnswers()
156
    {
157
        return $this->answers;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->answers; of type Doctrine\Common\Collecti...e\Entity\SurveyAnswer[] adds the type AppBundle\Entity\SurveyAnswer[] to the return on line 157 which is incompatible with the return type documented by AppBundle\Entity\SurveyQuestion::getAnswers of type Doctrine\Common\Collections\ArrayCollection.
Loading history...
158
    }
159
}
160