-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
I've created a patch to support using empty($this->config->customKey)
:
diff --git a/src/Config.php b/src/Config.php
index 9fa94e6..3f90975 100644
--- a/src/Config.php
+++ b/src/Config.php
@@ -44,6 +44,17 @@ class Config implements ServiceInterface
$this->config[$name] = $value;
}
+ /**
+ * isset config
+ *
+ * @param string $name
+ * @return boolean
+ */
+ public function __isset(string $name): bool
+ {
+ return isset($this->config[$name]);
+ }
+
/**
* check if has config
*
As indicated in these answers:
https://stackoverflow.com/a/2045833/3929620
https://stackoverflow.com/a/25574839/3929620
without the __isset()
method, $this->config->customKey
resolves to null
when checked with the empty()
function.
For example, even if $this->config->customKey
is not null
, the following if statement does not pass:
if($this->config->has('customKey') && !empty($this->config->customKey)) {
// This block is not executed
}
Do you think this is the right approach? Can I send you a PR?
barbanet
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Todo