Initial import from aternosorg/codex-minecraft
Some checks failed
Tests / Run tests on PHP v8.4 (push) Failing after 32s
Tests / Run tests on PHP v8.5 (push) Failing after 2s

This commit is contained in:
2026-04-30 09:56:57 -05:00
commit 7c7fe5ca80
94 changed files with 7003 additions and 0 deletions

66
src/Log/Level.php Normal file
View File

@@ -0,0 +1,66 @@
<?php
namespace Aternos\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;
}
}