Files
status-board/source/lib/StatusBoard/Status.class.php
Ben Roberts 13924c0b56 Add status comparison function
Simply checks the numerical value of status for now. If more statuses
are added in future, this check may need to be made more complex.
2011-12-17 12:37:23 +00:00

49 lines
1.7 KiB
PHP

<?php
class StatusBoard_Status {
const STATUS_Resolved = 0;
const STATUS_Maintenance = 1;
const STATUS_Minor = 2;
const STATUS_Significant = 3;
const STATUS_Major = 4;
protected static $names = array(
self::STATUS_Resolved => 'Resolved',
self::STATUS_Maintenance => 'Planned Maintenance',
self::STATUS_Minor => 'Minor Incident',
self::STATUS_Significant => 'Significant Incident',
self::STATUS_Major => 'Major Incident',
);
protected static $descriptions = array(
self::STATUS_Resolved => 'The service is operating normally.',
self::STATUS_Maintenance => 'The service is undergoing scheduled maintenance.',
self::STATUS_Minor => 'The service is exeriencing minor issues affecting some customers.',
self::STATUS_Significant => 'The service is exeriencing significant issues affecting many customers.',
self::STATUS_Major => 'The service is exeriencing a major outage affecting all customers.',
);
public static function name($status) {
if ( ! StatusBoard_Main::isClassConstantValue(get_called_class(), 'STATUS_', $status)) {
throw new StatusBoard_Exception_InvalidParameters($status);
}
return self::$names[$status];
}
public static function description($status) {
if ( ! StatusBoard_Main::isClassConstantValue(get_called_class(), 'STATUS_', $status)) {
throw new StatusBoard_Exception_InvalidParameters($status);
}
return self::$descriptions[$status];
}
public static function isMoreSevere($base, $test) {
return ($test > $base);
}
}
?>