Make default error value NULL, make data non-nullable

[MAILPOET-5599]
This commit is contained in:
Jan Jakes
2023-09-22 14:51:03 +02:00
committed by Aschepikov
parent c5f50b2a47
commit 7fac20fc8c
4 changed files with 12 additions and 11 deletions

View File

@@ -53,8 +53,8 @@ class AutomationRunLog {
/** @var array */
private $data = [];
/** @var array */
private $error = [];
/** @var array|null */
private $error;
public function __construct(
int $automationRunId,
@@ -147,7 +147,7 @@ class AutomationRunLog {
$this->updatedAt = new DateTimeImmutable();
}
public function getError(): array {
public function getError(): ?array {
return $this->error;
}
@@ -163,7 +163,7 @@ class AutomationRunLog {
'updated_at' => $this->updatedAt->format(DateTimeImmutable::W3C),
'run_number' => $this->runNumber,
'data' => Json::encode($this->data),
'error' => Json::encode($this->error),
'error' => $this->error ? Json::encode($this->error) : null,
];
}
@@ -189,7 +189,7 @@ class AutomationRunLog {
$log->updatedAt = new DateTimeImmutable($data['updated_at']);
$log->runNumber = (int)$data['run_number'];
$log->data = Json::decode($data['data']);
$log->error = Json::decode($data['error']);
$log->error = isset($data['error']) ? Json::decode($data['error']) : null;
return $log;
}