3 final class DiffusionCommitAuditStatus
extends Phobject
{
6 private $spec = array();
9 const NEEDS_AUDIT
= 'needs-audit';
10 const CONCERN_RAISED
= 'concern-raised';
11 const PARTIALLY_AUDITED
= 'partially-audited';
12 const AUDITED
= 'audited';
13 const NEEDS_VERIFICATION
= 'needs-verification';
15 public static function newModernKeys(array $values) {
16 $map = self
::getMap();
19 foreach ($map as $key => $spec) {
20 if (isset($spec['legacy'])) {
21 $modern[$spec['legacy']] = $key;
25 foreach ($values as $key => $value) {
26 $values[$key] = idx($modern, $value, $value);
32 public static function newForStatus($status) {
35 $result->key
= $status;
37 $map = self
::getMap();
38 if (isset($map[$status])) {
39 $result->spec
= $map[$status];
45 public function getKey() {
49 public function getIcon() {
50 return idx($this->spec
, 'icon');
53 public function getColor() {
54 return idx($this->spec
, 'color');
57 public function getAnsiColor() {
58 return idx($this->spec
, 'color.ansi');
61 public function getName() {
62 return idx($this->spec
, 'name', pht('Unknown ("%s")', $this->key
));
65 public function isNoAudit() {
66 return ($this->key
== self
::NONE
);
69 public function isNeedsAudit() {
70 return ($this->key
== self
::NEEDS_AUDIT
);
73 public function isConcernRaised() {
74 return ($this->key
== self
::CONCERN_RAISED
);
77 public function isNeedsVerification() {
78 return ($this->key
== self
::NEEDS_VERIFICATION
);
81 public function isPartiallyAudited() {
82 return ($this->key
== self
::PARTIALLY_AUDITED
);
85 public function isAudited() {
86 return ($this->key
== self
::AUDITED
);
89 public function getIsClosed() {
90 return idx($this->spec
, 'closed');
93 public static function getOpenStatusConstants() {
95 foreach (self
::getMap() as $key => $map) {
96 if (!$map['closed']) {
103 public static function newOptions() {
104 $map = self
::getMap();
105 return ipull($map, 'name');
108 public static function newDeprecatedOptions() {
109 $map = self
::getMap();
112 foreach ($map as $key => $spec) {
113 if (isset($spec['legacy'])) {
114 $results[$spec['legacy']] = $key;
121 private static function getMap() {
124 'name' => pht('No Audits'),
126 'icon' => 'fa-check',
127 'color' => 'bluegrey',
129 'color.ansi' => null,
131 self
::NEEDS_AUDIT
=> array(
132 'name' => pht('Audit Required'),
134 'icon' => 'fa-exclamation-circle',
137 'color.ansi' => 'magenta',
139 self
::CONCERN_RAISED
=> array(
140 'name' => pht('Concern Raised'),
142 'icon' => 'fa-times-circle',
145 'color.ansi' => 'red',
147 self
::PARTIALLY_AUDITED
=> array(
148 'name' => pht('Partially Audited'),
150 'icon' => 'fa-check-circle-o',
153 'color.ansi' => 'yellow',
155 self
::AUDITED
=> array(
156 'name' => pht('Audited'),
158 'icon' => 'fa-check-circle',
161 'color.ansi' => 'green',
163 self
::NEEDS_VERIFICATION
=> array(
164 'name' => pht('Needs Verification'),
166 'icon' => 'fa-refresh',
169 'color.ansi' => 'magenta',