2012-02-29 06:06:34 +01:00
|
|
|
<?php
|
|
|
|
|
2015-06-15 10:02:26 +02:00
|
|
|
final class PhabricatorAuditCommitStatusConstants extends Phobject {
|
2012-02-29 06:06:34 +01:00
|
|
|
|
2018-09-07 17:30:18 +02:00
|
|
|
private $key;
|
|
|
|
private $spec = array();
|
|
|
|
|
2012-02-29 06:06:34 +01:00
|
|
|
const NONE = 0;
|
|
|
|
const NEEDS_AUDIT = 1;
|
|
|
|
const CONCERN_RAISED = 2;
|
|
|
|
const PARTIALLY_AUDITED = 3;
|
|
|
|
const FULLY_AUDITED = 4;
|
2017-01-25 20:05:49 +01:00
|
|
|
const NEEDS_VERIFICATION = 5;
|
2012-02-29 06:06:34 +01:00
|
|
|
|
2018-09-05 19:26:02 +02:00
|
|
|
const MODERN_NONE = 'none';
|
|
|
|
const MODERN_NEEDS_AUDIT = 'needs-audit';
|
|
|
|
const MODERN_CONCERN_RAISED = 'concern-raised';
|
|
|
|
const MODERN_PARTIALLY_AUDITED = 'partially-audited';
|
|
|
|
const MODERN_AUDITED = 'audited';
|
|
|
|
const MODERN_NEEDS_VERIFICATION = 'needs-verification';
|
2012-02-29 06:06:34 +01:00
|
|
|
|
2018-09-07 17:30:18 +02:00
|
|
|
public static function newForLegacyStatus($status) {
|
|
|
|
$map = self::getMap();
|
|
|
|
|
2018-09-10 20:35:11 +02:00
|
|
|
if (is_int($status) || ctype_digit($status)) {
|
|
|
|
foreach ($map as $key => $spec) {
|
|
|
|
if ((int)idx($spec, 'legacy') === (int)$status) {
|
|
|
|
return self::newForStatus($key);
|
|
|
|
}
|
2018-09-07 17:30:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::newForStatus($status);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function newForStatus($status) {
|
|
|
|
$result = new self();
|
|
|
|
|
|
|
|
$result->key = $status;
|
|
|
|
|
|
|
|
$map = self::getMap();
|
|
|
|
if (isset($map[$status])) {
|
|
|
|
$result->spec = $map[$status];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getKey() {
|
|
|
|
return $this->key;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
return idx($this->spec, 'icon');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
return idx($this->spec, 'color');
|
|
|
|
}
|
|
|
|
|
2018-09-10 20:35:11 +02:00
|
|
|
public function getLegacyKey() {
|
|
|
|
return idx($this->spec, 'legacy');
|
|
|
|
}
|
|
|
|
|
2018-09-07 17:30:18 +02:00
|
|
|
public function getName() {
|
|
|
|
return idx($this->spec, 'name', pht('Unknown ("%s")', $this->key));
|
|
|
|
}
|
|
|
|
|
2018-09-07 18:01:30 +02:00
|
|
|
public function isNoAudit() {
|
|
|
|
return ($this->key == self::MODERN_NONE);
|
|
|
|
}
|
|
|
|
|
2018-09-10 20:35:11 +02:00
|
|
|
public function isNeedsAudit() {
|
|
|
|
return ($this->key == self::MODERN_NEEDS_AUDIT);
|
|
|
|
}
|
|
|
|
|
2018-09-07 18:01:30 +02:00
|
|
|
public function isConcernRaised() {
|
|
|
|
return ($this->key == self::MODERN_CONCERN_RAISED);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isNeedsVerification() {
|
|
|
|
return ($this->key == self::MODERN_NEEDS_VERIFICATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isPartiallyAudited() {
|
|
|
|
return ($this->key == self::MODERN_PARTIALLY_AUDITED);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isAudited() {
|
|
|
|
return ($this->key == self::MODERN_AUDITED);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsClosed() {
|
|
|
|
return idx($this->spec, 'closed');
|
|
|
|
}
|
|
|
|
|
2013-02-28 16:55:06 +01:00
|
|
|
public static function getOpenStatusConstants() {
|
2018-09-05 19:26:02 +02:00
|
|
|
$constants = array();
|
|
|
|
foreach (self::getMap() as $map) {
|
|
|
|
if (!$map['closed']) {
|
|
|
|
$constants[] = $map['legacy'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $constants;
|
2013-02-28 16:55:06 +01:00
|
|
|
}
|
|
|
|
|
2018-09-10 21:07:36 +02:00
|
|
|
public static function newOptions() {
|
2018-09-05 19:26:02 +02:00
|
|
|
$map = self::getMap();
|
2018-09-10 21:07:36 +02:00
|
|
|
return ipull($map, 'name');
|
2014-01-07 01:07:47 +01:00
|
|
|
}
|
|
|
|
|
2018-09-10 21:07:36 +02:00
|
|
|
public static function newDeprecatedOptions() {
|
2018-09-05 19:26:02 +02:00
|
|
|
$map = self::getMap();
|
2018-09-10 21:07:36 +02:00
|
|
|
|
|
|
|
$results = array();
|
|
|
|
foreach ($map as $key => $spec) {
|
|
|
|
if (isset($spec['legacy'])) {
|
|
|
|
$results[$spec['legacy']] = $key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
2015-06-19 14:18:42 +02:00
|
|
|
}
|
|
|
|
|
2018-09-05 19:26:02 +02:00
|
|
|
private static function getMap() {
|
|
|
|
return array(
|
|
|
|
self::MODERN_NONE => array(
|
|
|
|
'name' => pht('No Audits'),
|
|
|
|
'legacy' => self::NONE,
|
|
|
|
'icon' => 'fa-check',
|
|
|
|
'color' => 'bluegrey',
|
|
|
|
'closed' => true,
|
|
|
|
),
|
|
|
|
self::MODERN_NEEDS_AUDIT => array(
|
|
|
|
'name' => pht('Audit Required'),
|
|
|
|
'legacy' => self::NEEDS_AUDIT,
|
|
|
|
'icon' => 'fa-exclamation-circle',
|
|
|
|
'color' => 'orange',
|
|
|
|
'closed' => false,
|
|
|
|
),
|
|
|
|
self::MODERN_CONCERN_RAISED => array(
|
|
|
|
'name' => pht('Concern Raised'),
|
|
|
|
'legacy' => self::CONCERN_RAISED,
|
|
|
|
'icon' => 'fa-times-circle',
|
|
|
|
'color' => 'red',
|
|
|
|
'closed' => false,
|
|
|
|
),
|
|
|
|
self::MODERN_PARTIALLY_AUDITED => array(
|
|
|
|
'name' => pht('Partially Audited'),
|
|
|
|
'legacy' => self::PARTIALLY_AUDITED,
|
|
|
|
'icon' => 'fa-check-circle-o',
|
|
|
|
'color' => 'yellow',
|
|
|
|
'closed' => false,
|
|
|
|
),
|
|
|
|
self::MODERN_AUDITED => array(
|
|
|
|
'name' => pht('Audited'),
|
|
|
|
'legacy' => self::FULLY_AUDITED,
|
|
|
|
'icon' => 'fa-check-circle',
|
|
|
|
'color' => 'green',
|
|
|
|
'closed' => true,
|
|
|
|
),
|
|
|
|
self::MODERN_NEEDS_VERIFICATION => array(
|
|
|
|
'name' => pht('Needs Verification'),
|
|
|
|
'legacy' => self::NEEDS_VERIFICATION,
|
|
|
|
'icon' => 'fa-refresh',
|
|
|
|
'color' => 'indigo',
|
|
|
|
'closed' => false,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2012-02-29 06:06:34 +01:00
|
|
|
}
|