Source
* @param bool $force_normal True to return 'normal' class, false to return corresponding severity class.
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CSeverityHelper {
/**
* Get severity name by given state and configuration.
*
* @param int $severity
*
* @return string
*/
public static function getName(int $severity): string {
switch ($severity) {
case ZBX_SEVERITY_OK:
return _('OK');
case TRIGGER_SEVERITY_NOT_CLASSIFIED:
return _(CSettingsHelper::get(CSettingsHelper::SEVERITY_NAME_0));
case TRIGGER_SEVERITY_INFORMATION:
return _(CSettingsHelper::get(CSettingsHelper::SEVERITY_NAME_1));
case TRIGGER_SEVERITY_WARNING:
return _(CSettingsHelper::get(CSettingsHelper::SEVERITY_NAME_2));
case TRIGGER_SEVERITY_AVERAGE:
return _(CSettingsHelper::get(CSettingsHelper::SEVERITY_NAME_3));
case TRIGGER_SEVERITY_HIGH:
return _(CSettingsHelper::get(CSettingsHelper::SEVERITY_NAME_4));
case TRIGGER_SEVERITY_DISASTER:
return _(CSettingsHelper::get(CSettingsHelper::SEVERITY_NAME_5));
default:
return _('Unknown');
}
}
/**
* Get severity css style name.
*
* @param int|null $severity
* @param bool $type
*
* @return string|null
*/
public static function getStyle(?int $severity, bool $type = true): ?string {
if (!$type) {
return ZBX_STYLE_NORMAL_BG;
}
switch ($severity) {
case ZBX_SEVERITY_OK:
return ZBX_STYLE_NORMAL_BG;
case TRIGGER_SEVERITY_DISASTER: