[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 abstract class AphrontBarView extends AphrontView { 4 5 private $color; 6 private $caption = ''; 7 8 const COLOR_DEFAULT = 'default'; 9 const COLOR_WARNING = 'warning'; 10 const COLOR_DANGER = 'danger'; 11 12 const COLOR_AUTO_BADNESS = 'auto_badness'; // more = bad! :( 13 const COLOR_AUTO_GOODNESS = 'auto_goodness'; // more = good! :) 14 15 const THRESHOLD_DANGER = 0.85; 16 const THRESHOLD_WARNING = 0.75; 17 18 abstract protected function getRatio(); 19 20 abstract protected function getDefaultColor(); 21 22 final public function setColor($color) { 23 $this->color = $color; 24 return $this; 25 } 26 27 final public function setCaption($text) { 28 $this->caption = $text; 29 return $this; 30 } 31 32 final protected function getColor() { 33 $color = $this->color; 34 if (!$color) { 35 $color = $this->getDefaultColor(); 36 } 37 38 switch ($color) { 39 case self::COLOR_DEFAULT: 40 case self::COLOR_WARNING: 41 case self::COLOR_DANGER: 42 return $color; 43 } 44 45 $ratio = $this->getRatio(); 46 if ($color === self::COLOR_AUTO_GOODNESS) { 47 $ratio = 1.0 - $ratio; 48 } 49 50 if ($ratio >= self::THRESHOLD_DANGER) { 51 return self::COLOR_DANGER; 52 } else if ($ratio >= self::THRESHOLD_WARNING) { 53 return self::COLOR_WARNING; 54 } else { 55 return self::COLOR_DEFAULT; 56 } 57 } 58 59 final protected function getCaption() { 60 return $this->caption; 61 } 62 63 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |