Completed
Push — master ( 6a83c2...6c3c1b )
by Alessandro
04:16
created

ParaunitProcessAbstract::addWarning()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Paraunit\Process;
4
5
/**
6
 * Class SymfonyProcessWrapper.
7
 */
8
abstract class ParaunitProcessAbstract implements ParaunitProcessInterface, RetryAwareInterface, ProcessResultInterface
9
{
10
    /**
11
     * @var int
12
     */
13
    protected $retryCount = 0;
14
15
    /**
16
     * @var bool
17
     */
18
    protected $shouldBeRetried = false;
19
20
    /**
21
     * @var string
22
     */
23
    protected $uniqueId;
24
25
    /**
26
     * @var string
27
     */
28
    protected $filename;
29
30
    /**
31
     * @var string[]
32
     */
33
    protected $testResults;
34
35
    /**
36
     * @var string[]
37
     */
38
    protected $segmentationFaults;
39
40
    /**
41
     * @var string[]
42
     */
43
    protected $unknownStatus;
44
45
    /**
46
     * @var string[]
47
     */
48
    protected $fatalErrors;
49
50
    /**
51
     * @var string[]
52
     */
53
    protected $errors;
54
55
    /**
56
     * @var string[]
57
     */
58
    protected $failures;
59
60
    /**
61
     * @var string[]
62
     */
63
    protected $warnings;
64
65
    /**
66
     * @param string $commandLine
67
     */
68 37
    public function __construct($commandLine)
69
    {
70 37
        $this->uniqueId = md5($commandLine);
71
72 37
        $filename = array();
73 37
        if (preg_match('/[A-z]*\.php/', $commandLine, $filename) === 1) {
74 8
            $this->filename = $filename[0];
75 8
        }
76
77 37
        $this->testResults = array();
78 37
        $this->segmentationFaults = array();
79 37
        $this->unknownStatus = array();
80 37
        $this->fatalErrors = array();
81 37
        $this->errors = array();
82 37
        $this->failures = array();
83 37
        $this->warnings = array();
84 37
    }
85
86
    /**
87
     * @return string
88
     */
89 7
    public function getUniqueId()
90
    {
91 7
        return $this->uniqueId;
92
    }
93
94
    /**
95
     * @return int
96
     */
97 20
    public function getRetryCount()
98
    {
99 20
        return $this->retryCount;
100
    }
101
102
    /**
103
     */
104 4
    public function increaseRetryCount()
105
    {
106 4
        ++$this->retryCount;
107 4
    }
108
109
    /**
110
     */
111 7
    public function markAsToBeRetried()
112
    {
113 7
        $this->shouldBeRetried = true;
114 7
    }
115
116
    /**
117
     * @return bool
118
     */
119 35
    public function isToBeRetried()
120
    {
121 35
        return $this->shouldBeRetried;
122
    }
123
124
    /**
125
     * @return $this
126
     */
127 3
    public function reset()
128
    {
129 3
        $this->shouldBeRetried = false;
130 3
    }
131
132
    /**
133
     * @return string
134
     */
135 8
    public function getFilename()
136
    {
137 8
        return $this->filename;
138
    }
139
140
    /**
141
     * @return string[]
142
     */
143 28
    public function getTestResults()
144
    {
145 28
        return $this->testResults;
146
    }
147
148
    /**
149
     * @return string[]
150
     */
151 6
    public function getFatalErrors()
152
    {
153 6
        return $this->fatalErrors;
154
    }
155
156
    /**
157
     * @return string[]
158
     */
159 9
    public function getErrors()
160
    {
161 9
        return $this->errors;
162
    }
163
164
    /**
165
     * @return string[]
166
     */
167 6
    public function getFailures()
168
    {
169 6
        return $this->failures;
170
    }
171
172
    /**
173
     * @return string[]
174
     */
175 8
    public function getWarnings()
176
    {
177 8
        return $this->warnings;
178
    }
179
180
    /**
181
     * @param string[] $testResults
182
     */
183 27
    public function setTestResults(array $testResults)
184
    {
185 27
        $this->testResults = $testResults;
186 27
    }
187
188
    /**
189
     * @param string $segmentationFault
190
     */
191 3
    public function addSegmentationFault($segmentationFault)
192
    {
193 3
        $this->segmentationFaults[] = $segmentationFault;
194 3
    }
195
196
    /**
197
     * @param string $fatalError
198
     */
199 3
    public function addFatalError($fatalError)
200
    {
201 3
        $this->fatalErrors[] = $fatalError;
202 3
    }
203
204
    /**
205
     * @param string $error
206
     */
207 6
    public function addError($error)
208
    {
209 6
        $this->errors[] = $error;
210 6
    }
211
212
    /**
213
     * @param string $failure
214
     */
215 2
    public function addFailure($failure)
216
    {
217 2
        $this->failures[] = $failure;
218 2
    }
219
220
    /**
221
     * @param string $warning
222
     */
223 2
    public function addWarning($warning)
224
    {
225 2
        $this->warnings[] = $warning;
226 2
    }
227
228
    /**
229
     * @return bool
230
     */
231 13
    public function hasSegmentationFaults()
232
    {
233 13
        return count($this->segmentationFaults) > 0;
234
    }
235
236
    /**
237
     * @return bool
238
     */
239 7
    public function hasFatalErrors()
240
    {
241 7
        return count($this->fatalErrors) > 0;
242
    }
243
244
    /**
245
     * @return bool
246
     */
247 7
    public function hasErrors()
248
    {
249 7
        return count($this->errors) > 0;
250
    }
251
252
    /**
253
     * @return bool
254
     */
255 7
    public function hasFailures()
256
    {
257 7
        return count($this->failures) > 0;
258
    }
259
260
    /**
261
     * @return bool
262
     */
263 7
    public function hasWarnings()
264
    {
265 7
        return count($this->warnings) > 0;
266
    }
267
}
268