Completed
Branch output_parsers_refactor (69b7d7)
by Alessandro
02:50
created

ParaunitProcessAbstract   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Coupling/Cohesion

Components 5
Dependencies 0

Test Coverage

Coverage 95.45%

Importance

Changes 7
Bugs 3 Features 0
Metric Value
wmc 16
c 7
b 3
f 0
lcom 5
cbo 0
dl 0
loc 145
ccs 42
cts 44
cp 0.9545
rs 10

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
A getUniqueId() 0 4 1
A getRetryCount() 0 4 1
A increaseRetryCount() 0 4 1
A markAsToBeRetried() 0 4 1
A isToBeRetried() 0 4 1
A reset() 0 4 1
A getFilename() 0 4 1
A getTestResults() 0 4 1
A setTestResults() 0 4 1
A reportSegmentationFault() 0 4 1
A reportFatalError() 0 4 1
A hasSegmentationFaults() 0 4 1
A hasFatalErrors() 0 4 1
A isEmpty() 0 4 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->fatalErrors = false;
0 ignored issues
show
Bug introduced by
The property fatalErrors does not seem to exist. Did you mean fatalError?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
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