From 75897da9e9e219d55c39ec27275ced24606da9df Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 29 Jan 2025 15:26:36 -0500 Subject: [PATCH] Added SignatureKeyPair for a client object --- .../Objects/Client/SignatureKeyPair.php | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/Socialbox/Objects/Client/SignatureKeyPair.php diff --git a/src/Socialbox/Objects/Client/SignatureKeyPair.php b/src/Socialbox/Objects/Client/SignatureKeyPair.php new file mode 100644 index 0000000..c758db8 --- /dev/null +++ b/src/Socialbox/Objects/Client/SignatureKeyPair.php @@ -0,0 +1,100 @@ +uuid = $data['uuid']; + $this->name = $data['name'] ?? null; + $this->publicKey = $data['public_key']; + $this->privateKey = $data['private_key']; + $this->expires = (int)$data['expires'] ?? null; + } + + /** + * Returns the UUID of the key pair + * + * @return string The UUID of the key pair + */ + public function getUuid(): string + { + return $this->uuid; + } + + /** + * Returns the name of the key pair + * + * @return string|null The name of the key pair + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * Returns the public key of the key pair + * + * @return string The public key of the key pair + */ + public function getPublicKey(): string + { + return $this->publicKey; + } + + /** + * Returns the private key of the key pair + * + * @return string The private key of the key pair + */ + public function getPrivateKey(): string + { + return $this->privateKey; + } + + /** + * Returns the expiration date of the key pair + * + * @return int|null The expiration date of the key pair + */ + public function getExpires(): ?int + { + return $this->expires; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $data): SignatureKeyPair + { + return new self($data); + } + + /** + * @inheritDoc + */ + public function toArray(): array + { + return [ + 'uuid' => $this->uuid, + 'name' => $this->name, + 'public_key' => $this->publicKey, + 'private_key' => $this->privateKey, + 'expires' => $this->expires + ]; + } + } \ No newline at end of file