Driver = $driver; $this->Host = $host; $this->Port = $port; $this->Name = $name; $this->UserName = $userName; $this->Password = $password; $this->Chipper = $chipper; } /** * @inheritDoc */ public function UnSerialize (string $serialized): void { // Десериализую массив $array = json_decode($serialized, true); // Заполняю поля if (isset($array["host"])) $this->Host = $array["host"]; if (isset($array["port"])) $this->Port = $array["port"]; if (isset($array["name"])) $this->Name = $array["name"]; if (isset($array["user"])) $this->UserName = $array["user"]; if (isset($array["password"])) $this->Password = Encryptor::Decrypt($array["password"], $this->Chipper); if (isset($array["driver"])) $this->Driver = DBDriver::FromInt($array["driver"]); } /** * @inheritDoc */ public function Serialize (): string { // Создаю массив результата $result = []; // Заполняю массив $result["host"] = $this->Host; $result["port"] = $this->Port; $result["name"] = $this->Name; $result["user"] = $this->UserName; $result["password"] = Encryptor::Encrypt($this->Password, $this->Chipper); $result["driver"] = $this->Driver->ToInt(); // Сериализую return json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); } }