Completed
Push — output_parsers_refactor ( d2cb12...a7c18a )
by Alessandro
03:46
created

ParaunitProcessAbstract   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 133
Duplicated Lines 0 %

Coupling/Cohesion

Components 5
Dependencies 0

Test Coverage

Coverage 95.12%

Importance

Changes 15
Bugs 3 Features 0
Metric Value
wmc 15
c 15
b 3
f 0
lcom 5
cbo 0
dl 0
loc 133
ccs 39
cts 41
cp 0.9512
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A addTestResult() 0 4 1
A __construct() 0 12 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 hasAbnormalTermination() 0 4 1
A reportAbnormalTermination() 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 $abnormalTermination;
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 46
    public function __construct($commandLine, $uniqueId)
32
    {
33 46
        $this->uniqueId = $uniqueId;
34
35 46
        $filename = array();
36 46
        if (preg_match('/[A-z]*\.php/', $commandLine, $filename) === 1) {
37 8
            $this->filename = $filename[0];
38 8
        }
39
40 46
        $this->testResults = array();
41 46
        $this->abnormalTermination = false;
42 46
    }
43
44
    /**
45
     * @return string
46
     */
47 17
    public function getUniqueId()
48
    {
49 17
        return $this->uniqueId;
50
    }
51
52
    /**
53
     * @return int
54
     */
55 8
    public function getRetryCount()
56
    {
57 8
        return $this->retryCount;
58
    }
59
60
    /**
61
     */
62 4
    public function increaseRetryCount()
63
    {
64 4
        ++$this->retryCount;
65 4
    }
66
67
    /**
68
     */
69 7
    public function markAsToBeRetried()
70
    {
71 7
        $this->shouldBeRetried = true;
72 7
    }
73
74
    /**
75
     * @return bool
76
     */
77 21
    public function isToBeRetried()
78
    {
79 21
        return $this->shouldBeRetried;
80
    }
81
82
    /**
83
     * @return $this
84
     */
85 3
    public function reset()
86
    {
87 3
        $this->shouldBeRetried = false;
88 3
    }
89
90
    /**
91
     * @return string
92
     */
93 19
    public function getFilename()
94
    {
95 19
        return $this->filename;
96
    }
97
98
    /**
99
     * @return string[]
100
     */
101 39
    public function getTestResults()
102
    {
103 39
        return $this->testResults;
104
    }
105
106
    /**
107
     * @param string[] $testResults
108
     */
109 6
    public function setTestResults(array $testResults)
110
    {
111 6
        $this->testResults = $testResults;
112 6
    }
113
114 25
    public function addTestResult($testResult)
115
    {
116 25
        $this->testResults[] = $testResult;
117 25
    }
118
119
    /**
120
     * @return bool
121
     */
122 4
    public function hasAbnormalTermination()
123
    {
124 4
        return $this->abnormalTermination;
125
    }
126
127 6
    public function reportAbnormalTermination()
128
    {
129 6
        $this->abnormalTermination = true;
130 6
    }
131
132
    /**
133
     * @return bool
134
     * @deprecated
135
     */
136
    public function isEmpty()
137
    {
138
        return (bool) count($this->filename);
139
    }
140
}
141