3 final class HarbormasterBuildableStatus
extends Phobject
{
5 const STATUS_PREPARING
= 'preparing';
6 const STATUS_BUILDING
= 'building';
7 const STATUS_PASSED
= 'passed';
8 const STATUS_FAILED
= 'failed';
13 public function __construct($key, array $properties) {
15 $this->properties
= $properties;
18 public static function newBuildableStatusObject($status) {
19 $spec = self
::getSpecification($status);
20 return new self($status, $spec);
23 private function getProperty($key) {
24 if (!array_key_exists($key, $this->properties
)) {
27 'Attempting to access unknown buildable status property ("%s").',
31 return $this->properties
[$key];
34 public function getIcon() {
35 return $this->getProperty('icon');
38 public function getDisplayName() {
39 return $this->getProperty('name');
42 public function getActionName() {
43 return $this->getProperty('name.action');
46 public function getColor() {
47 return $this->getProperty('color');
50 public function isPreparing() {
51 return ($this->key
=== self
::STATUS_PREPARING
);
54 public function isBuilding() {
55 return ($this->key
=== self
::STATUS_BUILDING
);
58 public function isFailed() {
59 return ($this->key
=== self
::STATUS_FAILED
);
62 public static function getOptionMap() {
63 return ipull(self
::getSpecifications(), 'name');
66 private static function getSpecifications() {
68 self
::STATUS_PREPARING
=> array(
69 'name' => pht('Preparing'),
71 'icon' => 'fa-hourglass-o',
72 'name.action' => pht('Build Preparing'),
74 self
::STATUS_BUILDING
=> array(
75 'name' => pht('Building'),
77 'icon' => 'fa-chevron-circle-right',
78 'name.action' => pht('Build Started'),
80 self
::STATUS_PASSED
=> array(
81 'name' => pht('Passed'),
83 'icon' => 'fa-check-circle',
84 'name.action' => pht('Build Passed'),
86 self
::STATUS_FAILED
=> array(
87 'name' => pht('Failed'),
89 'icon' => 'fa-times-circle',
90 'name.action' => pht('Build Failed'),
95 private static function getSpecification($status) {
96 $map = self
::getSpecifications();
97 if (isset($map[$status])) {
102 'name' => pht('Unknown ("%s")', $status),
103 'icon' => 'fa-question-circle',
104 'color' => 'bluegrey',
105 'name.action' => pht('Build Status'),