Passed
Push — master ( 31593e...785a7b )
by FX
03:35
created

TestDTO::setSystemerr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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\DTO;
23
24
use AppBundle\Entity\Test;
25
use JMS\Serializer\Annotation\Type;
26
use Symfony\Component\Validator\Constraints as Assert;
27
28
/**
29
 * Test data transfert object class.
30
 *
31
 * @category  ci-report app
32
 *
33
 * @author    Francois-Xavier Soubirou <[email protected]>
34
 * @copyright 2017 Francois-Xavier Soubirou
35
 * @license   http://www.gnu.org/licenses/   GPLv3
36
 *
37
 * @see      https://www.ci-report.io
38
 */
39
class TestDTO
40
{
41
    /**
42
     * Name of the suite.
43
     *
44
     * @var string
45
     *
46
     * @Type("string")
47
     *
48
     * @Assert\NotBlank
49
     */
50
    private $name;
51
52
    /**
53
     * @var string
54
     *
55
     * @Type("string")
56
     */
57
    private $classname = '';
58
59
    /**
60
     * @var string
61
     *
62
     * @Type("string")
63
     */
64
    private $package = '';
65
66
    /**
67
     * @var int
68
     *
69
     * @Assert\Type("integer")
70
     * @Assert\GreaterThanOrEqual(0)
71
     */
72
    private $status;
73
74
    /**
75
     * @var float
76
     *
77
     * @Type("float")
78
     *
79
     * @Assert\Type("float")
80
     * @Assert\GreaterThanOrEqual(0)
81
     */
82
    private $duration = 0;
83
84
    /**
85
     * @var string
86
     *
87
     * @Type("string")
88
     */
89
    private $pbmessage = '';
90
91
    /**
92
     * @var string
93
     *
94
     * @Type("string")
95
     */
96
    private $systemout = '';
97
98
    /**
99
     * @var string
100
     *
101
     * @Type("string")
102
     */
103
    private $systemerr = '';
104
105
    /**
106
     * Set name.
107
     *
108
     * @param string $name
109
     *
110
     * @return TestDTO
111
     */
112
    public function setName(string $name): TestDTO
113
    {
114
        $this->name = $name;
115
116
        return $this;
117
    }
118
119
    /**
120
     * Get name.
121
     *
122
     * @return string
123
     */
124
    public function getName(): string
125
    {
126
        return $this->name;
127
    }
128
129
    /**
130
     * Set class name.
131
     *
132
     * @param string $classname Class name
133
     *
134
     * @return TestDTO
135
     */
136
    public function setClassname(string $classname): TestDTO
137
    {
138
        $this->classname = $classname;
139
140
        return $this;
141
    }
142
143
    /**
144
     * Get class name.
145
     *
146
     * @return string
147
     */
148
    public function getClassname(): string
149
    {
150
        return $this->classname;
151
    }
152
153
    /**
154
     * Set package.
155
     *
156
     * @param string $package Package of the test
157
     *
158
     * @return TestDTO
159
     */
160
    public function setPackage(string $package): TestDTO
161
    {
162
        $this->package = $package;
163
164
        return $this;
165
    }
166
167
    /**
168
     * Get package.
169
     *
170
     * @return string
171
     */
172
    public function getPackage(): string
173
    {
174
        return $this->package;
175
    }
176
177
    /**
178
     * Set full class name including package.
179
     *
180
     * @param string $fullclassname The full class name
181
     *
182
     * @return TestDTO
183
     */
184 View Code Duplication
    public function setFullclassname(string $fullclassname): TestDTO
185
    {
186
        if (substr_count($fullclassname, '.') > 0) {
187
            $index = strrpos($fullclassname, '.');
188
            $this->setPackage(substr($fullclassname, 0, $index));
189
            $this->setClassName(substr($fullclassname, $index + 1));
190
        } else {
191
            $this->setPackage(Test::DEFAULT_PACKAGE);
192
            $this->setClassName($fullclassname);
193
        }
194
195
        return $this;
196
    }
197
198
    /**
199
     * Set test status.
200
     *
201
     * @param int $status Status::SUCCESS|Status::FAILED|Status::ERROR|Status::SKIPPED
202
     *
203
     * @return TestDTO
204
     */
205
    public function setStatus(int $status): TestDTO
206
    {
207
        $this->status = $status;
208
209
        return $this;
210
    }
211
212
    /**
213
     * Return test status.
214
     *
215
     * @return int
216
     */
217
    public function getStatus(): int
218
    {
219
        return $this->status;
220
    }
221
222
    /**
223
     * Set duration of the suite in second.
224
     *
225
     * @param float $duration Duration
226
     *
227
     * @return TestDTO
228
     */
229
    public function setDuration(float $duration): TestDTO
230
    {
231
        $this->duration = $duration;
232
233
        return $this;
234
    }
235
236
    /**
237
     * Get duration of the suite in seconds.
238
     *
239
     * @return float
240
     */
241
    public function getDuration(): float
242
    {
243
        return $this->duration;
244
    }
245
246
    /**
247
     * Set message when error, fail, skip test.
248
     *
249
     * @param string $message The message
250
     *
251
     * @return TestDTO
252
     */
253
    public function setPbmessage(string $message): TestDTO
254
    {
255
        $this->pbmessage = $message;
256
257
        return $this;
258
    }
259
260
    /**
261
     * Get message set for errored, failed, skipped test.
262
     *
263
     * @return string
264
     */
265
    public function getPbmessage(): string
266
    {
267
        return $this->pbmessage;
268
    }
269
270
    /**
271
     * Set system out message.
272
     *
273
     * @param string $systemout The message
274
     *
275
     * @return TestDTO
276
     */
277
    public function setSystemout(string $systemout): TestDTO
278
    {
279
        $this->systemout = $systemout;
280
281
        return $this;
282
    }
283
284
    /**
285
     * Get system out message.
286
     *
287
     * @return string
288
     */
289
    public function getSystemout(): string
290
    {
291
        return $this->systemout;
292
    }
293
294
    /**
295
     * Set system error message.
296
     *
297
     * @param string $systemerr The message
298
     *
299
     * @return TestDTO
300
     */
301
    public function setSystemerr(string $systemerr): TestDTO
302
    {
303
        $this->systemerr = $systemerr;
304
305
        return $this;
306
    }
307
308
    /**
309
     * Get system error message.
310
     *
311
     * @return string
312
     */
313
    public function getSystemerr(): string
314
    {
315
        return $this->systemerr;
316
    }
317
}
318