Completed
Pull Request — dev (#24)
by
unknown
04:00
created

Survey::getCreatedAt()   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
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
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
use Symfony\Component\Serializer\Annotation\Groups;
10
11
/**
12
 * Survey.
13
 *
14
 * @ORM\Entity(repositoryClass="AppBundle\Repository\SurveyRepository")
15
 */
16
class Survey
17
{
18
    use ORMBehaviors\Timestampable\Timestampable;
19
20
    /**
21
     * @var int
22
     *
23
     * @ORM\Column(type="integer")
24
     * @ORM\Id
25
     * @ORM\GeneratedValue(strategy="AUTO")
26
     * @Groups({"group1"})
27
     */
28
    private $id;
29
30
    /**
31
     * @var SurveyType
32
     * @Assert\Type("object")
33
     * @Assert\Valid
34
     * @ORM\ManyToOne(targetEntity="SurveyType", inversedBy="surveys")
35
     * @Groups({"group1"})
36
     */
37
    private $type;
38
39
    /**
40
     * @var string
41
     * @Assert\NotBlank()
42
     * @Assert\Type("string")
43
     * @Assert\Length(
44
     *      max = 500
45
     * )
46
     * @ORM\Column(type="string")
47
     * @Groups({"group1"})
48
     */
49
    private $status = 'current';
50
51
    /**
52
     * @var User
53
     * @Assert\Type("object")
54
     * @Assert\Valid
55
     * @ORM\ManyToOne(targetEntity="User", inversedBy="surveys")
56
     */
57
    private $user;
58
59
    /**
60
     * @var ArrayCollection[SurveyQuestion]
61
     * @ORM\ManyToMany(targetEntity="SurveyQuestion", mappedBy="surveys")
62
     */
63
    private $questions;
64
65
    /**
66
     * @var ArrayCollection[SurveyAnswer]
67
     * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="survey")
68
     * @Groups({"group2"})
69
     */
70
    private $answers;
71
72
    public function __construct()
73
    {
74
        $this->questions = new ArrayCollection();
75
        $this->answers = new ArrayCollection();
76
    }
77
78
    /**
79
     * Get id.
80
     *
81
     * @return int
82
     */
83
    public function getId()
84
    {
85
        return $this->id;
86
    }
87
88
    /**
89
     * Set type.
90
     *
91
     * @param SurveyType $type
92
     *
93
     * @return Survey
94
     */
95
    public function setType(SurveyType $type)
96
    {
97
        $this->type = $type;
98
99
        return $this;
100
    }
101
102
    /**
103
     * Get type.
104
     *
105
     * @return SurveyType
106
     */
107
    public function getType()
108
    {
109
        return $this->type;
110
    }
111
112
    /**
113
     * Set status.
114
     *
115
     * @param string $status
116
     *
117
     * @return Survey
118
     */
119
    public function setStatus($status)
120
    {
121
        $this->status = $status;
122
123
        return $this;
124
    }
125
126
    /**
127
     * Get status.
128
     *
129
     * @return string
130
     */
131
    public function getStatus()
132
    {
133
        return $this->status;
134
    }
135
136
    /**
137
     * Set user.
138
     *
139
     * @param User $user
140
     *
141
     * @return Survey
142
     */
143
    public function setUser(User $user)
144
    {
145
        $this->user = $user;
146
147
        return $this;
148
    }
149
150
    /**
151
     * Get user.
152
     *
153
     * @return User
154
     */
155
    public function getUser()
156
    {
157
        return $this->user;
158
    }
159
160
    /**
161
     * @param SurveyQuestion $question
162
     *
163
     * @return Survey
164
     */
165
    public function setQuestions(SurveyQuestion $question)
166
    {
167
        if (!$this->questions->contains($question)) {
168
            $this->questions->add($question);
169
            $question->setSurveys($this);
170
        }
171
172
        return $this;
173
    }
174
175
    /**
176
     * Get Questions.
177
     *
178
     * @return ArrayCollection
179
     */
180
    public function getQuestions()
181
    {
182
        return $this->questions;
183
    }
184
185
    /**
186
     * Get Questions.
187
     *
188
     * @return ArrayCollection
189
     */
190
    public function getAnswers()
191
    {
192
        return $this->answers;
193
    }
194
195
    /**
196
     * Get DateTime.
197
     *
198
     * @return \DateTime
199
     * @Groups({"group1", "group2"})
200
     */
201
    public function getCreatedAt()
202
    {
203
        return $this->createdAt;
204
    }
205
206
    /**
207
     * Get DateTime.
208
     *
209
     * @return \DateTime
210
     * @Groups({"group1", "group2"})
211
     */
212
    public function getUpdatedAt()
213
    {
214
        return $this->updatedAt;
215
    }
216
}
217