소스 검색

Expand code a bit

Jordi Boggiano 1 년 전
부모
커밋
b56faa67a0
1개의 변경된 파일9개의 추가작업 그리고 6개의 파일을 삭제
  1. 9 6
      src/Monolog/LogRecord.php

+ 9 - 6
src/Monolog/LogRecord.php

@@ -76,13 +76,16 @@ class LogRecord implements ArrayAccess
 
     public function &offsetGet(mixed $offset): mixed
     {
-        if ($offset === 'level_name' || $offset === 'level') {
+        // handle special cases for the level enum
+        if ($offset === 'level_name') {
             // avoid returning readonly props by ref as this is illegal
-            if ($offset === 'level_name') {
-                $copy = $this->level->getName();
-            } else {
-                $copy = $this->level->value;
-            }
+            $copy = $this->level->getName();
+
+            return $copy;
+        }
+        if ($offset === 'level') {
+            // avoid returning readonly props by ref as this is illegal
+            $copy = $this->level->value;
 
             return $copy;
         }