Path: blob/master/src/applications/diffusion/DiffusionCommitAuditStatus.php
12241 views
<?php12final class DiffusionCommitAuditStatus extends Phobject {34private $key;5private $spec = array();67const NONE = 'none';8const NEEDS_AUDIT = 'needs-audit';9const CONCERN_RAISED = 'concern-raised';10const PARTIALLY_AUDITED = 'partially-audited';11const AUDITED = 'audited';12const NEEDS_VERIFICATION = 'needs-verification';1314public static function newModernKeys(array $values) {15$map = self::getMap();1617$modern = array();18foreach ($map as $key => $spec) {19if (isset($spec['legacy'])) {20$modern[$spec['legacy']] = $key;21}22}2324foreach ($values as $key => $value) {25$values[$key] = idx($modern, $value, $value);26}2728return $values;29}3031public static function newForStatus($status) {32$result = new self();3334$result->key = $status;3536$map = self::getMap();37if (isset($map[$status])) {38$result->spec = $map[$status];39}4041return $result;42}4344public function getKey() {45return $this->key;46}4748public function getIcon() {49return idx($this->spec, 'icon');50}5152public function getColor() {53return idx($this->spec, 'color');54}5556public function getAnsiColor() {57return idx($this->spec, 'color.ansi');58}5960public function getName() {61return idx($this->spec, 'name', pht('Unknown ("%s")', $this->key));62}6364public function isNoAudit() {65return ($this->key == self::NONE);66}6768public function isNeedsAudit() {69return ($this->key == self::NEEDS_AUDIT);70}7172public function isConcernRaised() {73return ($this->key == self::CONCERN_RAISED);74}7576public function isNeedsVerification() {77return ($this->key == self::NEEDS_VERIFICATION);78}7980public function isPartiallyAudited() {81return ($this->key == self::PARTIALLY_AUDITED);82}8384public function isAudited() {85return ($this->key == self::AUDITED);86}8788public function getIsClosed() {89return idx($this->spec, 'closed');90}9192public static function getOpenStatusConstants() {93$constants = array();94foreach (self::getMap() as $key => $map) {95if (!$map['closed']) {96$constants[] = $key;97}98}99return $constants;100}101102public static function newOptions() {103$map = self::getMap();104return ipull($map, 'name');105}106107public static function newDeprecatedOptions() {108$map = self::getMap();109110$results = array();111foreach ($map as $key => $spec) {112if (isset($spec['legacy'])) {113$results[$spec['legacy']] = $key;114}115}116117return $results;118}119120private static function getMap() {121return array(122self::NONE => array(123'name' => pht('No Audits'),124'legacy' => 0,125'icon' => 'fa-check',126'color' => 'bluegrey',127'closed' => true,128'color.ansi' => null,129),130self::NEEDS_AUDIT => array(131'name' => pht('Audit Required'),132'legacy' => 1,133'icon' => 'fa-exclamation-circle',134'color' => 'orange',135'closed' => false,136'color.ansi' => 'magenta',137),138self::CONCERN_RAISED => array(139'name' => pht('Concern Raised'),140'legacy' => 2,141'icon' => 'fa-times-circle',142'color' => 'red',143'closed' => false,144'color.ansi' => 'red',145),146self::PARTIALLY_AUDITED => array(147'name' => pht('Partially Audited'),148'legacy' => 3,149'icon' => 'fa-check-circle-o',150'color' => 'yellow',151'closed' => false,152'color.ansi' => 'yellow',153),154self::AUDITED => array(155'name' => pht('Audited'),156'legacy' => 4,157'icon' => 'fa-check-circle',158'color' => 'green',159'closed' => true,160'color.ansi' => 'green',161),162self::NEEDS_VERIFICATION => array(163'name' => pht('Needs Verification'),164'legacy' => 5,165'icon' => 'fa-refresh',166'color' => 'indigo',167'closed' => false,168'color.ansi' => 'magenta',169),170);171}172}173174175