Removed unused Encryption channel objects
This commit is contained in:
parent
29a3d42538
commit
e2b5bfab32
5 changed files with 0 additions and 1361 deletions
|
@ -1,160 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Objects\Database;
|
||||
|
||||
use DateMalformedStringException;
|
||||
use DateTime;
|
||||
use InvalidArgumentException;
|
||||
use Socialbox\Enums\Types\CommunicationRecipientType;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
use Socialbox\Objects\Standard\EncryptionChannelMessage;
|
||||
|
||||
class ChannelMessageRecord implements SerializableInterface
|
||||
{
|
||||
private string $uuid;
|
||||
private string $channelUuid;
|
||||
private CommunicationRecipientType $recipient;
|
||||
private string $message;
|
||||
private string $signature;
|
||||
private bool $received;
|
||||
private DateTime $timestamp;
|
||||
|
||||
/**
|
||||
* Constructs a new instance of this class and initializes its properties with the provided data.
|
||||
*
|
||||
* @param array $data An associative array containing initialization data. Expected keys:
|
||||
* - 'uuid' (string): The unique identifier.
|
||||
* - 'channel_uuid' (string): The channel UUID.
|
||||
* - 'recipient' (string): The recipient type, which will be cast to a CommunicationRecipientType instance.
|
||||
* - 'message' (string): The message.
|
||||
* - 'signature' (string): The signature.
|
||||
* - 'received' (bool): Whether the message has been received.
|
||||
* - 'timestamp' (int|string|\DateTime): The timestamp of the message.
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->uuid = $data['uuid'];
|
||||
$this->channelUuid = $data['channel_uuid'];
|
||||
$this->recipient = CommunicationRecipientType::from($data['recipient']);
|
||||
$this->message = $data['message'];
|
||||
$this->signature = $data['signature'];
|
||||
$this->received = (bool)$data['received'];
|
||||
|
||||
if($data['timestamp'] instanceof DateTime)
|
||||
{
|
||||
$this->timestamp = $data['timestamp'];
|
||||
}
|
||||
elseif(is_int($data['timestamp']))
|
||||
{
|
||||
$this->timestamp = (new DateTime())->setTimestamp($data['timestamp']);
|
||||
}
|
||||
elseif(is_string($data['timestamp']))
|
||||
{
|
||||
$this->timestamp = new DateTime($data['timestamp']);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidArgumentException('Invalid timestamp type, got ' . gettype($data['timestamp']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique identifier for the message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUuid(): string
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UUID of the channel that the message belongs to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getChannelUuid(): string
|
||||
{
|
||||
return $this->channelUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the recipient type of the message.
|
||||
*
|
||||
* @return CommunicationRecipientType
|
||||
*/
|
||||
public function getRecipient(): CommunicationRecipientType
|
||||
{
|
||||
return $this->recipient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signature of the message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSignature(): string
|
||||
{
|
||||
return $this->signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the message has been received.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isReceived(): bool
|
||||
{
|
||||
return $this->received;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp of the message.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getTimestamp(): DateTime
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ChannelMessageRecord
|
||||
{
|
||||
return new self($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'channel_uuid' => $this->channelUuid,
|
||||
'recipient' => $this->recipient->value,
|
||||
'message' => $this->message,
|
||||
'signature' => $this->signature,
|
||||
'received' => $this->received,
|
||||
'timestamp' => $this->timestamp->format('Y-m-d H:i:s')
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function toStandard(): EncryptionChannelMessage
|
||||
{
|
||||
return new EncryptionChannelMessage($this->toArray());
|
||||
}
|
||||
}
|
|
@ -1,256 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Objects\Database;
|
||||
|
||||
use DateTime;
|
||||
use InvalidArgumentException;
|
||||
use Socialbox\Enums\Status\EncryptionChannelState;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
use Socialbox\Objects\PeerAddress;
|
||||
use Socialbox\Objects\Standard\EncryptionChannel;
|
||||
|
||||
class EncryptionChannelRecord implements SerializableInterface
|
||||
{
|
||||
private string $uuid;
|
||||
private PeerAddress $callingPeer;
|
||||
private string $callingSignatureUuid;
|
||||
private string $callingEncryptionPublicKey;
|
||||
private PeerAddress $receivingPeer;
|
||||
private ?string $receivingSignatureUuid;
|
||||
private ?string $receivingEncryptionPublicKey;
|
||||
private string $transportEncryptionAlgorithm;
|
||||
private ?string $transportEncryptionKey;
|
||||
private EncryptionChannelState $state;
|
||||
private DateTime $created;
|
||||
|
||||
/**
|
||||
* Public Constructor for the encryption channel record
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->uuid = $data['uuid'];
|
||||
|
||||
if(!isset($data['calling_peer']))
|
||||
{
|
||||
throw new InvalidArgumentException('Missing property calling_peer');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_string($data['calling_peer']))
|
||||
{
|
||||
$this->callingPeer = PeerAddress::fromAddress($data['calling_peer']);
|
||||
}
|
||||
elseif($data['calling_peer'] instanceof PeerAddress)
|
||||
{
|
||||
$this->callingPeer = $data['calling_peer'];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidArgumentException('Unexpected calling_peer type, got ' . gettype($data['calling_peer']));
|
||||
}
|
||||
}
|
||||
|
||||
$this->callingSignatureUuid = $data['calling_signature_uuid'];
|
||||
$this->callingEncryptionPublicKey = $data['calling_encryption_public_key'];
|
||||
|
||||
if(!isset($data['receiving_peer']))
|
||||
{
|
||||
throw new InvalidArgumentException('Missing property receiving_peer');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_string($data['receiving_peer']))
|
||||
{
|
||||
$this->receivingPeer = PeerAddress::fromAddress($data['receiving_peer']);
|
||||
}
|
||||
elseif($data['receiving_peer'] instanceof PeerAddress)
|
||||
{
|
||||
$this->receivingPeer = $data['receiving_peer'];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidArgumentException('Unexpected receiving_peer type, got ' . gettype($data['receiving_peer']));
|
||||
}
|
||||
}
|
||||
|
||||
$this->receivingSignatureUuid = $data['receiving_signature_uuid'] ?? null;
|
||||
$this->receivingEncryptionPublicKey = $data['receiving_encryption_public_key'] ?? null;
|
||||
$this->transportEncryptionAlgorithm = $data['transport_encryption_algorithm'];
|
||||
$this->transportEncryptionKey = $data['transport_encryption_key'] ?? null;
|
||||
$this->state = EncryptionChannelState::tryFrom($data['state']) ?? EncryptionChannelState::ERROR;
|
||||
|
||||
if(!isset($data['created']))
|
||||
{
|
||||
throw new InvalidArgumentException('Missing property created');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_string($data['created']))
|
||||
{
|
||||
$this->created = new DateTime($data['created']);
|
||||
}
|
||||
elseif(is_int($data['created']))
|
||||
{
|
||||
$this->created = (new DateTime())->setTimestamp($data['created']);
|
||||
}
|
||||
elseif($data['created'] instanceof DateTime)
|
||||
{
|
||||
$this->created = $data['created'];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidArgumentException('Unexpected created type, got ' . gettype($data['created']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Unique Universal Identifier for the encryption record
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUuid(): string
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of the calling peer
|
||||
*
|
||||
* @return PeerAddress
|
||||
*/
|
||||
public function getCallingPeer(): PeerAddress
|
||||
{
|
||||
return $this->callingPeer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UUID of the signing keypair that the caller is using
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCallingSignatureUuid(): string
|
||||
{
|
||||
return $this->callingSignatureUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the public key of the encryption keypair that the caller is using
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCallingEncryptionPublicKey(): string
|
||||
{
|
||||
return $this->callingEncryptionPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of the receiving peer
|
||||
*
|
||||
* @return PeerAddress
|
||||
*/
|
||||
public function getReceivingPeer(): PeerAddress
|
||||
{
|
||||
return $this->receivingPeer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UUID of the signing keypair that the receiver is using
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReceivingSignatureUuid(): ?string
|
||||
{
|
||||
return $this->receivingSignatureUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the public key of the encryption keypair that the receiver is using
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReceivingEncryptionPublicKey(): ?string
|
||||
{
|
||||
return $this->receivingEncryptionPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the algorithm used for transport encryption
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTransportEncryptionAlgorithm(): string
|
||||
{
|
||||
return $this->transportEncryptionAlgorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key used for transport encryption
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTransportEncryptionKey(): ?string
|
||||
{
|
||||
return $this->transportEncryptionKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current state of the encryption channel
|
||||
*
|
||||
* @return EncryptionChannelState
|
||||
*/
|
||||
public function getState(): EncryptionChannelState
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the creation date of the encryption channel
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getCreated(): DateTime
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): EncryptionChannelRecord
|
||||
{
|
||||
return new self($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'calling_peer' => $this->callingPeer->getAddress(),
|
||||
'calling_signature_uuid' => $this->callingSignatureUuid,
|
||||
'calling_encryption_public_key' => $this->callingEncryptionPublicKey,
|
||||
'receiving_peer' => $this->receivingPeer->getAddress(),
|
||||
'receiving_signature_uuid' => $this->receivingSignatureUuid,
|
||||
'receiving_encryption_public_key' => $this->receivingEncryptionPublicKey,
|
||||
'transport_encryption_algorithm' => $this->transportEncryptionAlgorithm,
|
||||
'transport_encryption_key' => $this->transportEncryptionKey,
|
||||
'state' => $this->state->value,
|
||||
'created' => $this->created->format('Y-m-d H:i:s')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Encryption Channel Record to a Standard Encryption Channel
|
||||
*
|
||||
* @return EncryptionChannel
|
||||
*/
|
||||
public function toStandard(): EncryptionChannel
|
||||
{
|
||||
return new EncryptionChannel($this->toArray());
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Objects\Standard;
|
||||
|
||||
use DateTime;
|
||||
use InvalidArgumentException;
|
||||
use Socialbox\Enums\Status\EncryptionChannelState;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
|
||||
class EncryptionChannel implements SerializableInterface
|
||||
{
|
||||
private string $uuid;
|
||||
private string $callingPeer;
|
||||
private string $callingSignatureUuid;
|
||||
private string $callingSignaturePublicKey;
|
||||
private string $callingEncryptionPublicKey;
|
||||
private string $receivingPeer;
|
||||
private ?string $receivingSignatureUuid;
|
||||
private ?string $receivingSignaturePublicKey;
|
||||
private ?string $receivingEncryptionPublicKey;
|
||||
private string $transportEncryptionAlgorithm;
|
||||
private ?string $transportEncryptionKey;
|
||||
private EncryptionChannelState $state;
|
||||
private int $created;
|
||||
|
||||
/**
|
||||
* EncryptionChannel constructor.
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->uuid = $data['uuid'];
|
||||
$this->callingPeer = $data['calling_peer'];
|
||||
$this->callingSignatureUuid = $data['calling_signature_uuid'];
|
||||
$this->callingSignaturePublicKey = $data['calling_signature_public_key'];
|
||||
$this->callingEncryptionPublicKey = $data['calling_encryption_public_key'];
|
||||
$this->receivingPeer = $data['receiving_peer'];
|
||||
$this->receivingSignatureUuid = $data['receiving_signature_uuid'];
|
||||
$this->receivingSignaturePublicKey = $data['receiving_signature_public_key'];
|
||||
$this->receivingEncryptionPublicKey = $data['receiving_encryption_public_key'];
|
||||
$this->transportEncryptionAlgorithm = $data['transport_encryption_algorithm'];
|
||||
$this->transportEncryptionKey = $data['transport_encryption_key'];
|
||||
$this->state = EncryptionChannelState::from($data['state']);
|
||||
|
||||
if($data['created'] instanceof DateTime)
|
||||
{
|
||||
$this->created = $data['created']->getTimestamp();
|
||||
}
|
||||
elseif(is_int($data['created']))
|
||||
{
|
||||
$this->created = $data['created'];
|
||||
}
|
||||
elseif(is_string($data['created']))
|
||||
{
|
||||
$this->created = strtotime($data['created']) ?: throw new InvalidArgumentException('Invalid date format');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidArgumentException('Invalid date format, got type: ' . gettype($data['created']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Unique Universal Identifier of the Encryption Channel
|
||||
*
|
||||
* @return string The UUID of the Encryption Channel
|
||||
*/
|
||||
public function getUuid(): string
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Peer address that initiated the Encryption Channel
|
||||
*
|
||||
* @return string The Peer address that initiated the Encryption Channel
|
||||
*/
|
||||
public function getCallingPeer(): string
|
||||
{
|
||||
return $this->callingPeer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Unique Universal Identifier of the Signature used by the calling Peer
|
||||
*
|
||||
* @return string The UUID of the Signature used by the calling Peer
|
||||
*/
|
||||
public function getCallingSignatureUuid(): string
|
||||
{
|
||||
return $this->callingSignatureUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Public Key of the Signature used by the calling Peer
|
||||
*
|
||||
* @return string The Public Key of the Signature used by the calling Peer
|
||||
*/
|
||||
public function getCallingSignaturePublicKey(): string
|
||||
{
|
||||
return $this->callingSignaturePublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Public Key of the Encryption used by the calling Peer
|
||||
*
|
||||
* @return string The Public Key of the Encryption used by the calling Peer
|
||||
*/
|
||||
public function getCallingEncryptionPublicKey(): string
|
||||
{
|
||||
return $this->callingEncryptionPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Peer address that received the Encryption Channel
|
||||
*
|
||||
* @return string The Peer address that received the Encryption Channel
|
||||
*/
|
||||
public function getReceivingPeer(): string
|
||||
{
|
||||
return $this->receivingPeer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Unique Universal Identifier of the Signature used by the receiving Peer
|
||||
*
|
||||
* @return string|null The UUID of the Signature used by the receiving Peer, or null if not set
|
||||
*/
|
||||
public function getReceivingSignatureUuid(): ?string
|
||||
{
|
||||
return $this->receivingSignatureUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Public Key of the Signature used by the receiving Peer
|
||||
*
|
||||
* @return string|null The Public Key of the Signature used by the receiving Peer, or null if not set
|
||||
*/
|
||||
public function getReceivingSignaturePublicKey(): ?string
|
||||
{
|
||||
return $this->receivingSignaturePublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Public Key of the Encryption used by the receiving Peer
|
||||
*
|
||||
* @return string|null The Public Key of the Encryption used by the receiving Peer, or null if not set
|
||||
*/
|
||||
public function getReceivingEncryptionPublicKey(): ?string
|
||||
{
|
||||
return $this->receivingEncryptionPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Algorithm used for the Transport Encryption
|
||||
*
|
||||
* @return string The Algorithm used for the Transport Encryption
|
||||
*/
|
||||
public function getTransportEncryptionAlgorithm(): string
|
||||
{
|
||||
return $this->transportEncryptionAlgorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Key used for the Transport Encryption
|
||||
*
|
||||
* @return string|null The Key used for the Transport Encryption, or null if not set
|
||||
*/
|
||||
public function getTransportEncryptionKey(): ?string
|
||||
{
|
||||
return $this->transportEncryptionKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the State of the Encryption Channel
|
||||
*
|
||||
* @return EncryptionChannelState The State of the Encryption Channel
|
||||
*/
|
||||
public function getState(): EncryptionChannelState
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Unix Timestamp of the creation date of the Encryption Channel
|
||||
*
|
||||
* @return int The Unix Timestamp of the creation date of the Encryption Channel
|
||||
*/
|
||||
public function getCreated(): int
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): EncryptionChannel
|
||||
{
|
||||
return new self($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'calling_peer' => $this->callingPeer,
|
||||
'calling_signature_uuid' => $this->callingSignatureUuid,
|
||||
'calling_encryption_public_key' => $this->callingEncryptionPublicKey,
|
||||
'receiving_peer' => $this->receivingPeer,
|
||||
'receiving_signature_uuid' => $this->receivingSignatureUuid,
|
||||
'receiving_signature_public_key' => $this->receivingSignaturePublicKey,
|
||||
'receiving_encryption_public_key' => $this->receivingEncryptionPublicKey,
|
||||
'transport_encryption_algorithm' => $this->transportEncryptionAlgorithm,
|
||||
'transport_encryption_key' => $this->transportEncryptionKey,
|
||||
'state' => $this->state->value,
|
||||
'created' => $this->created
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Objects\Standard;
|
||||
|
||||
use DateTime;
|
||||
use InvalidArgumentException;
|
||||
use Socialbox\Enums\Types\CommunicationRecipientType;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
|
||||
class EncryptionChannelMessage implements SerializableInterface
|
||||
{
|
||||
private string $uuid;
|
||||
private string $channelUuid;
|
||||
private CommunicationRecipientType $recipient;
|
||||
private string $message;
|
||||
private string $signature;
|
||||
private bool $received;
|
||||
private int $timestamp;
|
||||
|
||||
/**
|
||||
* EncryptionChannelMessage constructor.
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->uuid = $data['uuid'];
|
||||
$this->channelUuid = $data['channel_uuid'];
|
||||
$this->recipient = CommunicationRecipientType::from($data['recipient']);
|
||||
$this->message = $data['message'];
|
||||
$this->signature = $data['signature'];
|
||||
$this->received = (bool)$data['received'];
|
||||
|
||||
if($data['timestamp'] instanceof DateTime)
|
||||
{
|
||||
$this->timestamp = $data['timestamp']->getTimestamp();
|
||||
}
|
||||
elseif(is_int($data['timestamp']))
|
||||
{
|
||||
$this->timestamp = $data['timestamp'];
|
||||
}
|
||||
elseif(is_string($data['timestamp']))
|
||||
{
|
||||
$this->timestamp = strtotime($data['timestamp']) ?: throw new InvalidArgumentException('Invalid date format');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidArgumentException('Invalid date format, got type: ' . gettype($data['timestamp']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Unique Universal Identifier of the message.
|
||||
*
|
||||
* @return string The UUID of the message.
|
||||
*/
|
||||
public function getUuid(): string
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Unique Universal Identifier of the channel.
|
||||
*
|
||||
* @return string The UUID of the channel.
|
||||
*/
|
||||
public function getChannelUuid(): string
|
||||
{
|
||||
return $this->channelUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* The recipient of the message.
|
||||
*
|
||||
* @return CommunicationRecipientType The recipient of the message.
|
||||
*/
|
||||
public function getRecipient(): CommunicationRecipientType
|
||||
{
|
||||
return $this->recipient;
|
||||
}
|
||||
|
||||
/**
|
||||
* The encrypted message.
|
||||
*
|
||||
* @return string The message.
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* The signature of the decrypted message.
|
||||
*
|
||||
* @return string The signature of the message.
|
||||
*/
|
||||
public function getSignature(): string
|
||||
{
|
||||
return $this->signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the message has been received.
|
||||
*
|
||||
* @return bool Whether the message has been received.
|
||||
*/
|
||||
public function isReceived(): bool
|
||||
{
|
||||
return $this->received;
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp of the message.
|
||||
*
|
||||
* @return int The timestamp of the message.
|
||||
*/
|
||||
public function getTimestamp(): int
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): EncryptionChannelMessage
|
||||
{
|
||||
return new self($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'channel_uuid' => $this->channelUuid,
|
||||
'recipient' => $this->recipient->value,
|
||||
'message' => $this->message,
|
||||
'signature' => $this->signature,
|
||||
'received' => $this->received,
|
||||
'timestamp' => $this->timestamp
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue