data; } /** * @param $key * @param $value * @return mixed */ public function setData($key, $value): mixed { return $this->data[$key] = $value; } /** * @param $key * @param bool $try * @param mixed $default * @return mixed * @throws */ public static function get($key, $try = FALSE, $default = null): mixed { $instance = Snowflake::app()->config->getData(); if (!str_contains($key, '.')) { return isset($instance[$key]) ? $instance[$key] : $default; } foreach (explode('.', $key) as $value) { if (empty($value)) { continue; } if (!isset($instance[$value])) { if ($try) { throw new ConfigException(sprintf(self::ERROR_MESSAGE, $key)); } return $default; } if (!is_array($instance[$value]) ) { return $instance[$value]; } $instance = $instance[$value]; } return empty($instance) ? $default : $instance; } /** * @param $key * @param $value * @return mixed * @throws Exception */ public static function set($key, $value): mixed { $config = Snowflake::app()->config; return $config->setData($key, $value); } /** * @param $key * @param bool $must_not_null * @return bool */ #[Pure] public static function has($key, $must_not_null = false): bool { $config = Snowflake::app()->config; if (!isset($config->data[$key])) { return false; } $config = $config->data[$key]; if ($must_not_null === false) { return true; } return !empty($config); } /** * @param $name * @param $value */ public function __set($name, $value) { $this->data[$name] = $value; } }