There is a php code:
public static function load() : void { $config = new ...; $config = $config->getData(); $throw = function() : void { throw new \ConfigException ("Invalid config."); }; self::$param1 = $config["core"]["param1"] ?? ($throw)(); self::$param2 = $config["core"]["param2"] ?? ($throw)(); self::$param3 = $config["module"]["param3"] ?? ($throw)(); self::$param4 = $config["module"]["param4"] ?? ($throw)(); } public static function getParam1() : bool { return self::$param1; } public static function getParam2() : string { return self::$param2; } public static function getParam3() : int {...} /*и т.д.*/ It checks the values in the array, and if they are not there, it throws an exception ($throw)() , if there is, then this value is assigned to the static property of the class.
In my opinion, now checking the value and throwing an exception looks awful. How can this be done better?
[ 'param1' => "core.param1", ... ]- teranparam1parameter names, etc. - teran