Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / DiffusionCommitAuditStatus.php
blob95d0e52213644215c88bca75b6cc9135200c0f85
1 <?php
3 final class DiffusionCommitAuditStatus extends Phobject {
5 private $key;
6 private $spec = array();
8 const NONE = 'none';
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();
18 $modern = array();
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);
29 return $values;
32 public static function newForStatus($status) {
33 $result = new self();
35 $result->key = $status;
37 $map = self::getMap();
38 if (isset($map[$status])) {
39 $result->spec = $map[$status];
42 return $result;
45 public function getKey() {
46 return $this->key;
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() {
94 $constants = array();
95 foreach (self::getMap() as $key => $map) {
96 if (!$map['closed']) {
97 $constants[] = $key;
100 return $constants;
103 public static function newOptions() {
104 $map = self::getMap();
105 return ipull($map, 'name');
108 public static function newDeprecatedOptions() {
109 $map = self::getMap();
111 $results = array();
112 foreach ($map as $key => $spec) {
113 if (isset($spec['legacy'])) {
114 $results[$spec['legacy']] = $key;
118 return $results;
121 private static function getMap() {
122 return array(
123 self::NONE => array(
124 'name' => pht('No Audits'),
125 'legacy' => 0,
126 'icon' => 'fa-check',
127 'color' => 'bluegrey',
128 'closed' => true,
129 'color.ansi' => null,
131 self::NEEDS_AUDIT => array(
132 'name' => pht('Audit Required'),
133 'legacy' => 1,
134 'icon' => 'fa-exclamation-circle',
135 'color' => 'orange',
136 'closed' => false,
137 'color.ansi' => 'magenta',
139 self::CONCERN_RAISED => array(
140 'name' => pht('Concern Raised'),
141 'legacy' => 2,
142 'icon' => 'fa-times-circle',
143 'color' => 'red',
144 'closed' => false,
145 'color.ansi' => 'red',
147 self::PARTIALLY_AUDITED => array(
148 'name' => pht('Partially Audited'),
149 'legacy' => 3,
150 'icon' => 'fa-check-circle-o',
151 'color' => 'yellow',
152 'closed' => false,
153 'color.ansi' => 'yellow',
155 self::AUDITED => array(
156 'name' => pht('Audited'),
157 'legacy' => 4,
158 'icon' => 'fa-check-circle',
159 'color' => 'green',
160 'closed' => true,
161 'color.ansi' => 'green',
163 self::NEEDS_VERIFICATION => array(
164 'name' => pht('Needs Verification'),
165 'legacy' => 5,
166 'icon' => 'fa-refresh',
167 'color' => 'indigo',
168 'closed' => false,
169 'color.ansi' => 'magenta',