config = include $configPath; } else { $this->config = [ 'smtp' => ['port' => 25, 'host' => '0.0.0.0', 'max_connections' => 100], 'pop3' => ['port' => 110, 'host' => '0.0.0.0', 'max_connections' => 100], 'server' => ['domain' => 'test.com', 'admin_password' => 'admin123', 'max_email_size' => 10485760], 'log' => ['path' => '../logs/', 'level' => 'info', 'max_file_size' => 10485760], 'mailbox' => ['max_size' => 104857600] ]; } } public function get($key, $default = null) { $keys = explode('.', $key); $value = $this->config; foreach ($keys as $k) { if (isset($value[$k])) { $value = $value[$k]; } else { return $default; } } return $value; } public function set($key, $value) { $keys = explode('.', $key); $config = &$this->config; foreach ($keys as $i => $k) { if ($i === count($keys) - 1) { $config[$k] = $value; } else { if (!isset($config[$k]) || !is_array($config[$k])) { $config[$k] = []; } $config = &$config[$k]; } } } public function save() { $configPath = __DIR__ . '/../config/config.php'; $content = "config, true) . ";\n"; return file_put_contents($configPath, $content) !== false; } public function getAll() { return $this->config; } }