|
@@ -10,7 +10,6 @@ trait ConfigTrait
|
|
|
public function __construct(private readonly ExtensionManager $extensionManager, private array $options = [])
|
|
public function __construct(private readonly ExtensionManager $extensionManager, private array $options = [])
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
public function getConfig(string $key = null): mixed
|
|
public function getConfig(string $key = null): mixed
|
|
|
{
|
|
{
|
|
|
if (empty($this->options)) {
|
|
if (empty($this->options)) {
|
|
@@ -33,4 +32,15 @@ trait ConfigTrait
|
|
|
{
|
|
{
|
|
|
return $this->getConfig($name) !== null;
|
|
return $this->getConfig($name) !== null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function __call(string $name, array $arguments): mixed
|
|
|
|
|
+ {
|
|
|
|
|
+ if (str_starts_with($name, 'get')) {
|
|
|
|
|
+ $name = lcfirst(substr($name, 3));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new \BadMethodCallException("Method {$name} does not exist.");
|
|
|
|
|
+ }
|
|
|
|
|
+ $name = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $name));
|
|
|
|
|
+ return $this->getConfig($name);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|