0) { return $default; } foreach ($array as $value) { $data = $data[$value] ?? null; if ($data === null) { if ($try) { throw new ConfigException(sprintf(self::ERROR_MESSAGE, $key)); } return $default; } } return $data; } /** * @param $key * @param $value * @return mixed */ public static function set($key, $value): mixed { $explode = explode('.', $key); $parent = &static::$data; foreach ($explode as $item) { if (!isset($parent[$item])) { $parent[$item] = []; } $parent = &$parent[$item]; } $parent = $value; unset($parent); return static::$data; } /** * @param $key * @param bool $must_not_null * @return bool */ public static function has($key, bool $must_not_null = false): bool { if (!isset(static::$data[$key])) { return false; } $config = static::$data[$key]; if ($must_not_null === false) { return true; } return !empty($config); } }