Files
ik-codex/src/Log/Level.php
indifferentketchup 66a2fcc5f3 Rename namespace Aternos\Codex to IndifferentKetchup\Codex
Bulk substitution across all PHP files in src/ and test/. Covers
namespace declarations, use statements, fully-qualified class
references, and @package PHPDoc tags. No logic changes.
2026-04-30 15:13:52 +00:00

67 lines
1.5 KiB
PHP

<?php
namespace IndifferentKetchup\Codex\Log;
enum Level: int implements LevelInterface
{
case EMERGENCY = 0;
case ALERT = 1;
case CRITICAL = 2;
case ERROR = 3;
case WARNING = 4;
case NOTICE = 5;
case INFO = 6;
case DEBUG = 7;
/**
* @param string $level
* @return Level
*/
public static function fromString(string $level): Level
{
return match (strtolower($level)) {
"emergency" => Level::EMERGENCY,
"alert" => Level::ALERT,
"critical", "severe", "fatal" => Level::CRITICAL,
"error", "stderr" => Level::ERROR,
"warning", "warn" => Level::WARNING,
"notice", "fine" => Level::NOTICE,
"debug", "finer", "finest" => Level::DEBUG,
default => Level::INFO
};
}
/**
* @return string
*/
public function asString(): string
{
return match ($this) {
Level::EMERGENCY => "emergency",
Level::ALERT => "alert",
Level::CRITICAL => "critical",
Level::ERROR => "error",
Level::WARNING => "warning",
Level::NOTICE => "notice",
Level::INFO => "info",
Level::DEBUG => "debug"
};
}
/**
* @return int
*/
public function asInt(): int
{
return $this->value;
}
/**
* @return int
*/
public function jsonSerialize(): int
{
return $this->value;
}
}