Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/constants/HarbormasterLintStatus.php
- This file was added.
<?php | |||||
final class HarbormasterLintStatus | |||||
extends Phobject { | |||||
public static function getLintStatusLabel($status) { | |||||
$map = self::getLintStatusDictionary($status); | |||||
$default = pht('Unknown Status ("%s")', $status); | |||||
return idx($map, 'label', $default); | |||||
} | |||||
public static function getLintStatusSort($status) { | |||||
$map = self::getLintStatusDictionary($status); | |||||
$default = 'N'; | |||||
return idx($map, 'sort', $default); | |||||
} | |||||
public static function summarizeStatuses(array $statuses) { | |||||
if (!$statuses) { | |||||
return null; | |||||
} | |||||
$map = self::getLintStatusMap(); | |||||
$map = ipull($map, 'sort'); | |||||
$default = 'Z'; | |||||
$summary = head($statuses); | |||||
$w_index = idx($map, $summary, $default); | |||||
foreach ($statuses as $status) { | |||||
$r = idx($map, $status, $default); | |||||
if ($r < $w_index) { | |||||
$summary = $status; | |||||
$w_index = $r; | |||||
} | |||||
} | |||||
return $summary; | |||||
} | |||||
public static function getDifferentialLintStatus($status) { | |||||
$map = self::getLintStatusDictionary($status); | |||||
return idx($map, 'differential_value', $status); | |||||
} | |||||
private static function getLintStatusDictionary($status) { | |||||
$map = self::getLintStatusMap(); | |||||
$default = array(); | |||||
return idx($map, $status, $default); | |||||
} | |||||
private static function getLintStatusMap() { | |||||
return array( | |||||
ArcanistLintSeverity::SEVERITY_ERROR => array( | |||||
'differential_value' => DifferentialLintStatus::LINT_FAIL, | |||||
'label' => pht('Error'), | |||||
'sort' => 'A', | |||||
), | |||||
ArcanistLintSeverity::SEVERITY_WARNING => array( | |||||
'differential_value' => DifferentialLintStatus::LINT_WARN, | |||||
'label' => pht('Warning'), | |||||
'sort' => 'B', | |||||
), | |||||
ArcanistLintSeverity::SEVERITY_ADVICE => array( | |||||
'differential_value' => DifferentialLintStatus::LINT_OKAY, | |||||
'label' => pht('Advice'), | |||||
'sort' => 'Y', | |||||
), | |||||
); | |||||
} | |||||
} |