Completed
Push — output_parsers_refactor ( 710907...9ffc6c )
by Alessandro
02:42
created

ParaunitProcessAbstract::isToBeRetried()   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 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
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
    /** @var int */
11
    protected $retryCount = 0;
12
13
    /** @var bool */
14
    protected $shouldBeRetried = false;
15
16
    /** @var string */
17
    protected $uniqueId;
18
19
    /** @var string */
20
    protected $filename;
21
22
    /** @var string[] */
23
    protected $testResults;
24
25
    /** @var bool */
26
    protected $segmentationFault;
27
28
    /** @var bool */
29
    protected $fatalError;
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 51
    public function __construct($commandLine, $uniqueId)
35
    {
36 51
        $this->uniqueId = $uniqueId;
37
38 51
        $filename = array();
39 51
        if (preg_match('/[A-z]*\.php/', $commandLine, $filename) === 1) {
40 8
            $this->filename = $filename[0];
41 8
        }
42
43 51
        $this->testResults = array();
44
45 51
        $this->segmentationFault = false;
46 51
        $this->fatalError = false;
47 51
    }
48
49
    /**
50
     * @return string
51
     */
52 8
    public function getUniqueId()
53
    {
54 8
        return $this->uniqueId;
55
    }
56
57
    /**
58
     * @return int
59
     */
60 20
    public function getRetryCount()
61
    {
62 20
        return $this->retryCount;
63
    }
64
65
    /**
66
     */
67 4
    public function increaseRetryCount()
68
    {
69 4
        ++$this->retryCount;
70 4
    }
71
72
    /**
73
     */
74 7
    public function markAsToBeRetried()
75
    {
76 7
        $this->shouldBeRetried = true;
77 7
    }
78
79
    /**
80
     * @return bool
81
     */
82 37
    public function isToBeRetried()
83
    {
84 37
        return $this->shouldBeRetried;
85
    }
86
87
    /**
88
     * @return $this
89
     */
90 3
    public function reset()
91
    {
92 3
        $this->shouldBeRetried = false;
93 3
    }
94
95
    /**
96
     * @return string
97
     */
98 14
    public function getFilename()
99
    {
100 14
        return $this->filename;
101
    }
102
103
    /**
104
     * @return string[]
105
     */
106 39
    public function getTestResults()
107
    {
108 39
        return $this->testResults;
109
    }
110
111
    /**
112
     * @param string[] $testResults
113
     */
114 24
    public function setTestResults(array $testResults)
115
    {
116 24
        $this->testResults = $testResults;
117 24
    }
118
119 9
    public function addTestResult($testResult)
120
    {
121 9
        $this->testResults[] = $testResult;
122 9
    }
123
124
    /**
125
     * @deprecated
126
     */
127 3
    public function reportSegmentationFault()
128
    {
129 3
        $this->segmentationFault = true;
130 3
    }
131
132
    /**
133
     * @deprecated
134
     */
135 3
    public function reportFatalError()
136
    {
137 3
        $this->fatalError = true;
138 3
    }
139
140
    /**
141
     * @return bool
142
     * @deprecated
143
     */
144 29
    public function hasSegmentationFaults()
145
    {
146 29
        return $this->segmentationFault;
147
    }
148
149
    /**
150
     * @return bool
151
     * @deprecated
152
     */
153 26
    public function hasfatalErrors()
154
    {
155 26
        return $this->fatalError;
156
    }
157
158
    /**
159
     * @return bool
160
     * @deprecated
161
     */
162
    public function isEmpty()
163
    {
164
        return (bool) count($this->filename);
165
    }
166
}
167