Completed
Push — output_parsers_refactor ( 14be94...cf2136 )
by Alessandro
03:20
created

ParaunitProcessAbstract::hasfatalErrors()   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
Metric Value
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
     * @param string $commandLine
33
     */
34 39
    public function __construct($commandLine)
35
    {
36 39
        $this->uniqueId = md5($commandLine);
37
38 39
        $filename = array();
39 39
        if (preg_match('/[A-z]*\.php/', $commandLine, $filename) === 1) {
40 8
            $this->filename = $filename[0];
41 8
        }
42
43 39
        $this->testResults = array();
44
45 39
        $this->segmentationFault = false;
46 39
        $this->fatalError = false;
47 39
    }
48
49
    /**
50
     * @return string
51
     */
52 7
    public function getUniqueId()
53
    {
54 7
        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 29
    public function getTestResults()
107
    {
108 29
        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 3
    public function reportSegmentationFault()
120
    {
121 3
        $this->segmentationFault = true;
122 3
    }
123
124 3
    public function reportFatalError()
125
    {
126 3
        $this->fatalError = true;
127 3
    }
128
129
    /**
130
     * @return bool
131
     */
132 29
    public function hasSegmentationFaults()
133
    {
134 29
        return $this->segmentationFault;
135
    }
136
137
    /**
138
     * @return bool
139
     */
140 26
    public function hasfatalErrors()
141
    {
142 26
        return $this->fatalError;
143
    }
144
145
    /**
146
     * @return bool
147
     */
148
    public function isEmpty()
149
    {
150
        return (bool) count($this->filename);
151
    }
152
}
153