Error handling fixes
This commit is contained in:
@ -29,16 +29,16 @@ class Message implements JsonSerializable
|
||||
|
||||
private array $messageData;
|
||||
|
||||
public function __construct(string $messageType, array $messageData = [], ?string $uuid = null)
|
||||
public function __construct(string $messageType, array $messageData = [], null|string|false $uuid = null)
|
||||
{
|
||||
$this->uuid = $uuid ?? (string)Uuid::v7();
|
||||
$this->uuid = ($uuid===null) ? (string)Uuid::v7() : $uuid;
|
||||
$this->messageType = $messageType;
|
||||
$this->messageData = $messageData;
|
||||
}
|
||||
|
||||
public function getUuid(): string
|
||||
{
|
||||
return $this->uuid;
|
||||
return $this->uuid ? $this->uuid : "";
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
@ -63,7 +63,7 @@ class Message implements JsonSerializable
|
||||
if (!$json || empty($json['msg'])) {
|
||||
throw new MessageException("Invalid data");
|
||||
}
|
||||
return new Message($json['msg'], $json['data'], $json['uuid']??"");
|
||||
return new Message($json['msg'], $json['data'], $json['uuid']??false);
|
||||
}
|
||||
|
||||
public function asResult($result): Message
|
||||
|
Reference in New Issue
Block a user