Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/constants/DifferentialLintStatus.php
12256 views
1
<?php
2
3
final class DifferentialLintStatus extends Phobject {
4
5
const LINT_NONE = 0;
6
const LINT_OKAY = 1;
7
const LINT_WARN = 2;
8
const LINT_FAIL = 3;
9
const LINT_SKIP = 4;
10
const LINT_AUTO_SKIP = 6;
11
12
private $value;
13
14
public static function newStatusFromValue($value) {
15
$status = new self();
16
$status->value = $value;
17
return $status;
18
}
19
20
public function getValue() {
21
return $this->value;
22
}
23
24
public function getName() {
25
$name = $this->getLintStatusProperty('name');
26
27
if ($name === null) {
28
$name = pht('Unknown Lint Status ("%s")', $this->getValue());
29
}
30
31
return $name;
32
}
33
34
public function getIconIcon() {
35
return $this->getLintStatusProperty('icon.icon');
36
}
37
38
public function getIconColor() {
39
return $this->getLintStatusProperty('icon.color');
40
}
41
42
public static function getStatusMap() {
43
$results = array();
44
45
foreach (self::newLintStatusMap() as $value => $ignored) {
46
$results[$value] = self::newStatusFromValue($value);
47
}
48
49
return $results;
50
}
51
52
private function getLintStatusProperty($key, $default = null) {
53
$map = self::newLintStatusMap();
54
$properties = idx($map, $this->getValue(), array());
55
return idx($properties, $key, $default);
56
}
57
58
private static function newLintStatusMap() {
59
return array(
60
self::LINT_NONE => array(
61
'name' => pht('No Lint Coverage'),
62
'icon.icon' => 'fa-ban',
63
'icon.color' => 'grey',
64
),
65
self::LINT_OKAY => array(
66
'name' => pht('Lint Passed'),
67
'icon.icon' => 'fa-check',
68
'icon.color' => 'green',
69
),
70
self::LINT_WARN => array(
71
'name' => pht('Lint Warnings'),
72
'icon.icon' => 'fa-exclamation-triangle',
73
'icon.color' => 'yellow',
74
),
75
self::LINT_FAIL => array(
76
'name' => pht('Lint Errors'),
77
'icon.icon' => 'fa-times',
78
'icon.color' => 'red',
79
),
80
self::LINT_SKIP => array(
81
'name' => pht('Lint Skipped'),
82
'icon.icon' => 'fa-fast-forward',
83
'icon.color' => 'blue',
84
),
85
self::LINT_AUTO_SKIP => array(
86
'name' => pht('Lint Not Applicable'),
87
'icon.icon' => 'fa-code',
88
'icon.color' => 'grey',
89
),
90
);
91
}
92
93
}
94
95