Skip to content

Commit 3e27d99

Browse files
committed
feat: add get and has check on config props
1 parent 666731d commit 3e27d99

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/Configs/ConfigPropsFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static function create(array $props): ConfigPropsInterface
2323
}
2424

2525
if (!class_exists($name)) {
26-
return self::resolver();
26+
return self::resolver($props);
2727
}
2828

2929
return new $name($props);

src/DispatchConfig.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
use MaplePHP\Emitron\Configs\ConfigPropsFactory;
1919
use MaplePHP\Emitron\Contracts\ConfigPropsInterface;
2020
use MaplePHP\Emitron\Contracts\DispatchConfigInterface;
21-
use MaplePHP\Unitary\Config\ConfigProps;
2221
use MaplePHP\Unitary\Interfaces\RouterDispatchInterface;
2322
use MaplePHP\Unitary\Interfaces\RouterInterface;
24-
use MaplePHP\Unitary\Support\Helpers;
2523

2624
class DispatchConfig implements DispatchConfigInterface
2725
{
@@ -40,6 +38,28 @@ public function __construct(string|null|ConfigPropsInterface $props = null)
4038
}
4139
}
4240

41+
/**
42+
* Get config value
43+
*
44+
* @param string $key
45+
* @return mixed
46+
*/
47+
public function get(string $key): mixed
48+
{
49+
return $this->props->{$key};
50+
}
51+
52+
/**
53+
* Check if config prop exists
54+
*
55+
* @param string $key
56+
* @return bool
57+
*/
58+
public function has(string $key): bool
59+
{
60+
return isset($this->props->{$key});
61+
}
62+
4363
/**
4464
* Get instance of ConfigProps
4565
*

0 commit comments

Comments
 (0)