-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathResult.php
More file actions
173 lines (150 loc) · 3.61 KB
/
Result.php
File metadata and controls
173 lines (150 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
namespace PHP_Parallel_Lint\PhpParallelLint;
use JsonSerializable;
use PHP_Parallel_Lint\PhpParallelLint\Errors\ParallelLintError;
use PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError;
use ReturnTypeWillChange;
class Result implements JsonSerializable
{
/** @var ParallelLintError[] */
private $errors;
/** @var array */
private $checkedFiles;
/** @var array */
private $skippedFiles;
/** @var float */
private $testTime;
/**
* @param ParallelLintError[] $errors
* @param array $checkedFiles
* @param array $skippedFiles
* @param float $testTime
*/
public function __construct(array $errors, array $checkedFiles, array $skippedFiles, $testTime)
{
$this->errors = $errors;
$this->checkedFiles = $checkedFiles;
$this->skippedFiles = $skippedFiles;
$this->testTime = $testTime;
}
/**
* @return ParallelLintError[]
*/
public function getErrors()
{
return $this->errors;
}
/**
* @return bool
*/
public function hasError()
{
return !empty($this->errors);
}
/**
* @return array
*/
public function getFilesWithFail()
{
$filesWithFail = array();
foreach ($this->errors as $error) {
if (!$error instanceof SyntaxError) {
$filesWithFail[] = $error->getFilePath();
}
}
return $filesWithFail;
}
/**
* @return int
*/
public function getFilesWithFailCount()
{
return count($this->getFilesWithFail());
}
/**
* @return bool
*/
public function hasFilesWithFail()
{
return $this->getFilesWithFailCount() !== 0;
}
/**
* @return array
*/
public function getCheckedFiles()
{
return $this->checkedFiles;
}
/**
* @return int
*/
public function getCheckedFilesCount()
{
return count($this->checkedFiles);
}
/**
* @return array
*/
public function getSkippedFiles()
{
return $this->skippedFiles;
}
/**
* @return int
*/
public function getSkippedFilesCount()
{
return count($this->skippedFiles);
}
/**
* @return array
*/
public function getFilesWithSyntaxError()
{
$filesWithSyntaxError = array();
foreach ($this->errors as $error) {
if ($error instanceof SyntaxError) {
$filesWithSyntaxError[] = $error->getFilePath();
}
}
return $filesWithSyntaxError;
}
/**
* @return int
*/
public function getFilesWithSyntaxErrorCount()
{
return count($this->getFilesWithSyntaxError());
}
/**
* @return bool
*/
public function hasSyntaxError()
{
return $this->getFilesWithSyntaxErrorCount() !== 0;
}
/**
* @return float
*/
public function getTestTime()
{
return $this->testTime;
}
/**
* (PHP 5 >= 5.4.0)<br/>
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize()
{
return array(
'checkedFiles' => $this->getCheckedFiles(),
'filesWithSyntaxError' => $this->getFilesWithSyntaxError(),
'skippedFiles' => $this->getSkippedFiles(),
'errors' => $this->getErrors(),
);
}
}