Browse Source

feat(config):为配置特征添加魔术方法支持

- 实现 __isset 魔术方法以检查配置项是否存在
- 当配置值不为 null 时返回 true,否则返回 false
runphp 6 tháng trước cách đây
mục cha
commit
c2258516fb
1 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 5 0
      src/Trait/ConfigTrait.php

+ 5 - 0
src/Trait/ConfigTrait.php

@@ -28,4 +28,9 @@ trait ConfigTrait
     {
         return $this->getConfig($name);
     }
+
+    public function __isset(string $name): bool
+    {
+        return $this->getConfig($name) !== null;
+    }
 }