Test   A
last analyzed

Complexity

Total Complexity 24

Size/Duplication

Total Lines 335
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 95.52%

Importance

Changes 0
Metric Value
wmc 24
lcom 2
cbo 1
dl 0
loc 335
ccs 64
cts 67
cp 0.9552
rs 10
c 0
b 0
f 0

23 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 4 1
A jsonSerialize() 0 13 1
A getId() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A setActual() 0 6 1
A getActual() 0 4 1
A setExpectation() 0 6 1
A getExpectation() 0 4 1
A setExpected() 0 6 1
A getExpected() 0 4 1
A setCreatedAt() 0 8 2
A getCreatedAt() 0 4 1
A setUpdatedAt() 0 6 1
A getUpdatedAt() 0 4 1
A setGroup() 0 6 1
A getGroup() 0 4 1
A addResult() 0 6 1
A removeResult() 0 4 1
A getResults() 0 4 1
A setLastResult() 0 6 1
A getLastResult() 0 4 1
1
<?php
2
3
namespace Overwatch\TestBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * Test
9
 *
10
 * @ORM\Table(
11
 *   name="Test",
12
 *   uniqueConstraints={
13
 *     @ORM\UniqueConstraint(name="unique_actual_expection", columns={"actual", "expectation"})
14
 *   }
15
 * )
16
 * @ORM\Entity(repositoryClass="Overwatch\TestBundle\Entity\TestRepository")
17
 * @ORM\HasLifecycleCallbacks
18
 */
19
class Test implements \JsonSerializable
20
{
21
    /**
22
     * @var integer
23
     *
24
     * @ORM\Column(name="id", type="integer")
25
     * @ORM\Id
26
     * @ORM\GeneratedValue(strategy="AUTO")
27
     */
28
    private $id;
29
30
    /**
31
     * @var string
32
     *
33
     * @ORM\Column(name="name", type="string", length=50, unique=true)
34
     */
35
    private $name;
36
37
    /**
38
     * @var string
39
     *
40
     * @ORM\Column(name="actual", type="string", length=100)
41
     */
42
    private $actual;
43
44
    /**
45
     * @var string
46
     *
47
     * @ORM\Column(name="expectation", type="string", length=50)
48
     */
49
    private $expectation;
50
51
    /**
52
     * @var string
53
     *
54
     * @ORM\Column(name="expected", type="string", length=100, nullable=true)
55
     */
56
    private $expected;
57
    
58
    /**
59
     * @ORM\OneToMany(targetEntity="Overwatch\ResultBundle\Entity\TestResult", mappedBy="test")
60
     */
61
    private $results;
62
    
63
    /**
64
     * @ORM\OneToOne(targetEntity="Overwatch\ResultBundle\Entity\TestResult")
65
     * @ORM\JoinColumn(name="lastResult_id", referencedColumnName="id", onDelete="SET NULL")
66
     */
67
    private $lastResult;
68
    
69
    /**
70
     * @ORM\ManyToOne(targetEntity="TestGroup", inversedBy="tests")
71
     */
72
    private $group;
73
74
    /**
75
     * @var \DateTime
76
     *
77
     * @ORM\Column(name="created_at", type="datetime")
78
     */
79
    private $createdAt;
80
81
    /**
82
     * @var \DateTime
83
     *
84
     * @ORM\Column(name="updated_at", type="datetime")
85
     */
86
    private $updatedAt;
87
    
88
89
    /**
90
     * Constructor
91
     */
92 148
    public function __construct()
93
    {
94 148
        $this->results = new \Doctrine\Common\Collections\ArrayCollection();
95 148
    }
96
    
97
    /**
98
     * To String
99
     * 
100
     * @return string
101
     */
102 4
    public function __toString()
103
    {
104 4
        return $this->getName();
105
    }
106
    
107
    /**
108
     * Serialise object to JSON
109
     */
110 10
    public function jsonSerialize()
111
    {
112
        return [
113 10
            'id'          => $this->getId(),
114 10
            'name'        => $this->getName(),
115 10
            'actual'      => $this->getActual(),
116 10
            'expectation' => $this->getExpectation(),
117 10
            'expected'    => $this->getExpected(),
118 10
            'result'      => $this->getLastResult(),
119 10
            'createdAt'   => $this->getCreatedAt()->getTimestamp(),
120 10
            'updatedAt'   => $this->getUpdatedAt()->getTimestamp()
121 10
        ];
122
    }
123
    
124
    /**
125
     * Get id
126
     *
127
     * @return integer 
128
     */
129 18
    public function getId()
130
    {
131 18
        return $this->id;
132
    }
133
134
    /**
135
     * Set name
136
     *
137
     * @param string $name
138
     * @return Test
139
     */
140 137
    public function setName($name)
141
    {
142 137
        $this->name = $name;
143
144 137
        return $this;
145
    }
146
147
    /**
148
     * Get name
149
     *
150
     * @return string 
151
     */
152 128
    public function getName()
153
    {
154 128
        return $this->name;
155
    }
156
157
    /**
158
     * Set actual
159
     *
160
     * @param string $actual
161
     * @return Test
162
     */
163 135
    public function setActual($actual)
164
    {
165 135
        $this->actual = $actual;
166
167 135
        return $this;
168
    }
169
170
    /**
171
     * Get actual
172
     *
173
     * @return string 
174
     */
175 28
    public function getActual()
176
    {
177 28
        return $this->actual;
178
    }
179
180
    /**
181
     * Set expectation
182
     *
183
     * @param string $expectation
184
     * @return Test
185
     */
186 135
    public function setExpectation($expectation)
187
    {
188 135
        $this->expectation = $expectation;
189
190 135
        return $this;
191
    }
192
193
    /**
194
     * Get expectation
195
     *
196
     * @return string 
197
     */
198 28
    public function getExpectation()
199
    {
200 28
        return $this->expectation;
201
    }
202
203
    /**
204
     * Set expected
205
     *
206
     * @param string $expected
207
     * @return Test
208
     */
209 3
    public function setExpected($expected)
210
    {
211 3
        $this->expected = $expected;
212
213 3
        return $this;
214
    }
215
216
    /**
217
     * Get expected
218
     *
219
     * @return string 
220
     */
221 26
    public function getExpected()
222
    {
223 26
        return $this->expected;
224
    }
225
226
    /**
227
     * Set createdAt
228
     *
229
     * @ORM\PrePersist
230
     * @return Test
231
     */
232 129
    public function setCreatedAt()
233
    {
234 129
        if ($this->createdAt === null) {
235 129
            $this->createdAt = new \DateTime;
236 129
        }
237
        
238 129
        return $this;
239
    }
240
241
    /**
242
     * Get createdAt
243
     *
244
     * @return \DateTime 
245
     */
246 11
    public function getCreatedAt()
247
    {
248 11
        return $this->createdAt;
249
    }
250
251
    /**
252
     * Set updatedAt
253
     *
254
     * @ORM\PrePersist
255
     * @ORM\PreUpdate
256
     * @return Test
257
     */
258 129
    public function setUpdatedAt()
259
    {
260 129
        $this->updatedAt = new \DateTime;
261
262 129
        return $this;
263
    }
264
265
    /**
266
     * Get updatedAt
267
     *
268
     * @return \DateTime 
269
     */
270 10
    public function getUpdatedAt()
271
    {
272 10
        return $this->updatedAt;
273
    }
274
275
    /**
276
     * Set group
277
     *
278
     * @param \Overwatch\TestBundle\Entity\TestGroup $group
279
     * @return Test
280
     */
281 127
    public function setGroup(\Overwatch\TestBundle\Entity\TestGroup $group = null)
282
    {
283 127
        $this->group = $group;
284
285 127
        return $this;
286
    }
287
288
    /**
289
     * Get group
290
     *
291
     * @return \Overwatch\TestBundle\Entity\TestGroup 
292
     */
293 127
    public function getGroup()
294
    {
295 127
        return $this->group;
296
    }
297
298
    /**
299
     * Add results
300
     *
301
     * @param \Overwatch\ResultBundle\Entity\TestResult $result
302
     * @return Test
303
     */
304 1
    public function addResult(\Overwatch\ResultBundle\Entity\TestResult $result)
305
    {
306 1
        $this->results[] = $result;
307
308 1
        return $this;
309
    }
310
311
    /**
312
     * Remove results
313
     *
314
     * @param \Overwatch\ResultBundle\Entity\TestResult $result
315
     */
316
    public function removeResult(\Overwatch\ResultBundle\Entity\TestResult $result)
317
    {
318
        $this->results->removeElement($result);
319
    }
320
321
    /**
322
     * Get results
323
     *
324
     * @return \Doctrine\Common\Collections\Collection 
325
     */
326 3
    public function getResults()
327
    {
328 3
        return $this->results;
329
    }
330
    
331
    /**
332
     * Set last result
333
     * 
334
     * @param \Overwatch\ResultBundle\Entity\TestResult $result
335
     * @return \Overwatch\TestBundle\Entity\Test
336
     */
337 135
    public function setLastResult(\Overwatch\ResultBundle\Entity\TestResult $result)
338
    {
339 135
        $this->lastResult = $result;
340
        
341 135
        return $this;
342
    }
343
    
344
    /**
345
     * Get last result
346
     * 
347
     * @return \Overwatch\ResultBundle\Entity\TestResult
348
     */
349 10
    public function getLastResult()
350
    {
351 10
        return $this->lastResult;
352
    }
353
}
354