Passed
Branch master (9d818b)
by FX
07:15 queued 02:51
created

Project::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Copyright (c) 2017 Francois-Xavier Soubirou.
4
 *
5
 * This file is part of ci-report.
6
 *
7
 * ci-report is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * ci-report is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with ci-report. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
declare(strict_types=1);
21
22
namespace AppBundle\Entity;
23
24
use Datetime;
25
use Doctrine\ORM\Mapping as ORM;
26
use JMS\Serializer\Annotation as Serializer;
27
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
28
use Symfony\Component\Validator\Constraints as Assert;
29
30
/**
31
 * Project entity class.
32
 *
33
 * @category  ci-report app
34
 *
35
 * @author    Francois-Xavier Soubirou <[email protected]>
36
 * @copyright 2017 Francois-Xavier Soubirou
37
 * @license   http://www.gnu.org/licenses/   GPLv3
38
 *
39
 * @see      https://ci-report.io
40
 *
41
 * @ORM\Table(name="cir_project")
42
 * @ORM\Entity(repositoryClass="AppBundle\Repository\ProjectRepository")
43
 * @ORM\HasLifecycleCallbacks()
44
 *
45
 * @UniqueEntity("name", groups={"input"})
46
 */
47
class Project
48
{
49
    const DEFAULT_WARNING_LIMIT = 80;
50
    const DEFAULT_SUCCESS_LIMIT = 95;
51
52
    /**
53
     * @var int
54
     *
55
     * @ORM\Column(name="id", type="integer")
56
     * @ORM\Id
57
     * @ORM\GeneratedValue(strategy="AUTO")
58
     *
59
     * @Serializer\Exclude
60
     */
61
    private $id;
62
63
    /**
64
     * Name of the project.
65
     *
66
     * @var string
67
     *
68
     * @ORM\Column(name="name", type="string", length=50, unique=true)
69
     *
70
     * @Assert\NotBlank(groups={"input"})
71
     *
72
     * @Serializer\Groups({"public", "private"})
73
     */
74
    private $name;
75
76
    /**
77
     * Unique short name of project defined on project creation.
78
     *
79
     * @var string
80
     *
81
     * @ORM\Column(name="refid", type="string", length=50, unique=true)
82
     *
83
     * @Serializer\Groups({"public", "private"})
84
     */
85
    private $refId;
86
87
    /**
88
     * @var string
89
     *
90
     * @ORM\Column(name="token", type="string", length=50)
91
     *
92
     * @Serializer\Exclude
93
     */
94
    private $token;
95
96
    /**
97
     * Tests warning limit.
98
     *
99
     * @var int
100
     *
101
     * @ORM\Column(name="warning_limit", type="smallint")
102
     *
103
     * @Assert\NotBlank(message="warning_limit value should not be blank.", groups={"input"})
104
     *
105
     * @Serializer\Groups({"public", "private"})
106
     */
107
    private $warningLimit;
108
109
    /**
110
     * Tests success limit.
111
     *
112
     * @var int
113
     *
114
     * @ORM\Column(name="success_limit", type="smallint")
115
     *
116
     * @Assert\NotBlank(message="success_limit value should not be blank.", groups={"input"})
117
     *
118
     * @Serializer\Groups({"public", "private"})
119
     */
120
    private $successLimit;
121
122
    /**
123
     * Email.
124
     *
125
     * @var string
126
     *
127
     * @ORM\Column(name="email", type="string", length=50)
128
     *
129
     * @Assert\NotBlank(groups={"input"})
130
     * @Assert\Email(strict=true, groups={"input"})
131
     *
132
     * @Serializer\Groups({"private"})
133
     */
134
    private $email;
135
136
    /**
137
     * @var DateTime
138
     *
139
     * @ORM\Column(name="created", type="datetime")
140
     *
141
     * @Serializer\Exclude
142
     */
143
    private $created;
144
145
    /**
146
     * Constructor.
147
     */
148
    public function __construct()
149
    {
150
        $this->setWarningLimit(self::DEFAULT_WARNING_LIMIT);
151
        $this->setSuccessLimit(self::DEFAULT_SUCCESS_LIMIT);
152
    }
153
154
    /**
155
     * Triggered on insert.
156
     *
157
     * @ORM\PrePersist
158
     */
159
    public function onPrePersist()
160
    {
161
        $this->created = new DateTime();
162
    }
163
164
    /**
165
     * Get id.
166
     *
167
     * @return int
168
     */
169
    public function getId(): int
170
    {
171
        return $this->id;
172
    }
173
174
    /**
175
     * Set name.
176
     *
177
     * @param string $name
178
     *
179
     * @return Project
180
     */
181
    public function setName(string $name): Project
182
    {
183
        $this->name = $name;
184
185
        return $this;
186
    }
187
188
    /**
189
     * Get name.
190
     *
191
     * @return string
192
     */
193
    public function getName(): string
194
    {
195
        return $this->name;
196
    }
197
198
    /**
199
     * Set refId.
200
     *
201
     * @param string $refId
202
     *
203
     * @return Project
204
     */
205
    public function setRefId(string $refId): Project
206
    {
207
        $this->refId = $refId;
208
209
        return $this;
210
    }
211
212
    /**
213
     * Get refId.
214
     *
215
     * @return string
216
     */
217
    public function getRefId(): string
218
    {
219
        return $this->refId;
220
    }
221
222
    /**
223
     * Set token.
224
     *
225
     * @param string $token
226
     *
227
     * @return Project
228
     */
229
    public function setToken(string $token): Project
230
    {
231
        $this->token = $token;
232
233
        return $this;
234
    }
235
236
    /**
237
     * Get token.
238
     *
239
     * @return string
240
     */
241
    public function getToken(): string
242
    {
243
        return $this->token;
244
    }
245
246
    /**
247
     * Set warning limit.
248
     *
249
     * @param int $warningLimit
250
     *
251
     * @return Project
252
     */
253
    public function setWarningLimit(int $warningLimit): Project
254
    {
255
        $this->warningLimit = $warningLimit;
256
257
        return $this;
258
    }
259
260
    /**
261
     * Get warning limit.
262
     *
263
     * @return int
264
     */
265
    public function getWarningLimit(): ?int
266
    {
267
        return $this->warningLimit;
268
    }
269
270
    /**
271
     * Set success limit.
272
     *
273
     * @param int $successLimit
274
     *
275
     * @return Project
276
     */
277
    public function setSuccessLimit(int $successLimit): Project
278
    {
279
        $this->successLimit = $successLimit;
280
281
        return $this;
282
    }
283
284
    /**
285
     * Get success limit.
286
     *
287
     * @return int
288
     */
289
    public function getSuccessLimit(): ?int
290
    {
291
        return $this->successLimit;
292
    }
293
294
    /**
295
     * Set email.
296
     *
297
     * @param string $email
298
     *
299
     * @return Project
300
     */
301
    public function setEmail(string $email): Project
302
    {
303
        $this->email = $email;
304
305
        return $this;
306
    }
307
308
    /**
309
     * Get email.
310
     *
311
     * @return string
312
     */
313
    public function getEmail(): string
314
    {
315
        return $this->email;
316
    }
317
318
    /**
319
     * Get created date.
320
     *
321
     * @return Datetime
322
     */
323
    public function getCreated(): ?Datetime
324
    {
325
        return $this->created;
326
    }
327
}
328