Completed
Push — dev ( f2abe4...3f06d3 )
by nonanerz
05:36 queued 05:30
created

FormRequest::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
7
use Symfony\Component\Serializer\Annotation\Groups;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * FormRequest.
12
 *
13
 * @ORM\Entity(repositoryClass="AppBundle\Repository\FormRequestRepository")
14
 */
15
class FormRequest
16
{
17
    use ORMBehaviors\Timestampable\Timestampable;
18
19
    const STATUS = ['pending', 'approved', 'rejected'];
20
    const TYPE = ['personal day', 'overnight guest', 'sick day'];
21
22
    /**
23
     * @var int
24
     *
25
     * @ORM\Column(name="id", type="integer")
26
     * @ORM\Id
27
     * @ORM\GeneratedValue(strategy="AUTO")
28
     */
29
    private $id;
30
31
    /**
32
     * @var string
33
     * @Assert\NotBlank()
34
     * @Assert\Choice({FormRequest::TYPE})
35
     * @ORM\Column(type="string", length=25)
36
     * @Groups({"Detail"})
37
     */
38
    private $type;
39
40
    /**
41
     * @var string
42
     * @Assert\NotBlank()
43
     * @Assert\Type("string")
44
     * @Assert\Length(
45
     *      max = 255
46
     * )
47
     * @ORM\Column(type="string", length=255)
48
     * @Groups({"Detail"})
49
     */
50
    private $status;
51
52
    /**
53
     * @var User
54
     * @Assert\Type("object")
55
     * @Assert\Valid
56
     * @ORM\ManyToOne(targetEntity="User", inversedBy="formRequests")
57
     */
58
    private $user;
59
60
    /**
61
     * @var \DateTime
62
     * @Assert\DateTime()
63
     * @ORM\Column(type="datetime")
64
     * @Groups({"Detail"})
65
     */
66
    private $date;
67
68
    public function __construct()
69
    {
70
        $this->setStatus("pending");
71
    }
72
73
    /**
74
     * Get id.
75
     *
76
     * @return int
77
     */
78 1
    public function getId()
79
    {
80 1
        return $this->id;
81
    }
82
83
    /**
84
     * Set type.
85
     *
86
     * @param $type
87
     *
88
     * @return FormRequest
89
     */
90
    public function setType($type)
91
    {
92
        if (in_array($type, self::TYPE)) {
93
            $this->type = $type;
94
        }
95
        return $this;
96
    }
97
98
    /**
99
     * Get type.
100
     *
101
     * @return string
102
     */
103 1
    public function getType()
104
    {
105 1
        return $this->type;
106
    }
107
108
    /**
109
     * Set status.
110
     *
111
     * @param string $status
112
     *
113
     * @return FormRequest
114
     */
115
    public function setStatus($status)
116
    {
117
        if (in_array($status, self::STATUS)) {
118
            $this->status = $status;
119
        }
120
        return $this;
121
    }
122
123
    /**
124
     * Get status.
125
     *
126
     * @return string
127
     */
128 1
    public function getStatus()
129
    {
130 1
        return $this->status;
131
    }
132
133
    /**
134
     * Set user.
135
     *
136
     * @param User $user
137
     *
138
     * @return FormRequest
139
     */
140
    public function setUser(User $user)
141
    {
142
        $this->user = $user;
143
144
        return $this;
145
    }
146
147
    /**
148
     * Get user.
149
     *
150
     * @return User
151
     */
152
    public function getUser()
153
    {
154
        return $this->user;
155
    }
156
157
    /**
158
     * Set date.
159
     *
160
     * @param \DateTime $date
161
     *
162
     * @return FormRequest
163
     */
164
    public function setDate($date)
165
    {
166
        $this->date = new \DateTime($date);
167
168
        return $this;
169
    }
170
    /**
171
     * Get date.
172
     *
173
     * @return \DateTime
174
     */
175 1
    public function getDate()
176
    {
177 1
        return $this->date;
178
    }
179
}
180