From b96759b4e645b470e0c8895df2473d63cceb14eb Mon Sep 17 00:00:00 2001 From: Netkas Date: Thu, 5 May 2022 19:50:19 +0100 Subject: [PATCH] Added NccUpdateInformation object --- src/ncc/Objects/NccUpdateInformation.php | 128 +++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 src/ncc/Objects/NccUpdateInformation.php diff --git a/src/ncc/Objects/NccUpdateInformation.php b/src/ncc/Objects/NccUpdateInformation.php new file mode 100644 index 0000000..5d67e36 --- /dev/null +++ b/src/ncc/Objects/NccUpdateInformation.php @@ -0,0 +1,128 @@ +AuthenticationRequired = false; + $this->Flags = []; + $this->ChangeLog = []; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'version' => $this->Version, + 'download_source' => $this->DownloadSource, + 'authentication_required' => $this->AuthenticationRequired, + 'authentication_username' => $this->AuthenticationUsername, + 'authentication_password' => $this->AuthenticationPassword, + 'flags' => $this->Flags, + 'update_description' => $this->UpdateDescription, + 'changelog' => $this->ChangeLog + ]; + } + + /** + * Constructs an object from an array representation + * + * @param array $data + * @return NccUpdateInformation + */ + public static function fromArray(array $data): NccUpdateInformation + { + $NccUpdateInformationObject = new NccUpdateInformation(); + + if(isset($data['version'])) + $NccUpdateInformationObject->Version = $data['version']; + + if(isset($data['download_source'])) + $NccUpdateInformationObject->DownloadSource = $data['download_source']; + + if(isset($data['authentication_required'])) + $NccUpdateInformationObject->AuthenticationRequired = $data['authentication_required']; + + if(isset($data['authentication_username'])) + $NccUpdateInformationObject->AuthenticationUsername = $data['authentication_username']; + + if(isset($data['authentication_password'])) + $NccUpdateInformationObject->AuthenticationPassword = $data['authentication_password']; + + if(isset($data['flags'])) + $NccUpdateInformationObject->Flags = $data['flags']; + + if(isset($data['update_description'])) + $NccUpdateInformationObject->UpdateDescription = $data['update_description']; + + if(isset($data['changelog'])) + $NccUpdateInformationObject->ChangeLog = $data['changelog']; + + return $NccUpdateInformationObject; + } + } \ No newline at end of file