1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-01 19:00:20 +02:00

Add strtolower for fromName match statement (#1941)

Changes the `fromName` method to be case-insensitive for more flexible use.
This commit is contained in:
Alan Jones
2025-03-15 13:06:02 +00:00
committed by GitHub
parent 548eeb3f1e
commit 353f1db2e4

View File

@@ -87,15 +87,15 @@ enum Level: int
*/
public static function fromName(string $name): self
{
return match ($name) {
'debug', 'Debug', 'DEBUG' => self::Debug,
'info', 'Info', 'INFO' => self::Info,
'notice', 'Notice', 'NOTICE' => self::Notice,
'warning', 'Warning', 'WARNING' => self::Warning,
'error', 'Error', 'ERROR' => self::Error,
'critical', 'Critical', 'CRITICAL' => self::Critical,
'alert', 'Alert', 'ALERT' => self::Alert,
'emergency', 'Emergency', 'EMERGENCY' => self::Emergency,
return match (strtolower($name)) {
'debug' => self::Debug,
'info' => self::Info,
'notice' => self::Notice,
'warning' => self::Warning,
'error' => self::Error,
'critical' => self::Critical,
'alert' => self::Alert,
'emergency' => self::Emergency,
};
}