From f49b6a072c03e6c00a3cdd2fd30d936430a949ea Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 10 Jan 2022 18:03:48 +0200 Subject: [PATCH] refactoring --- application/Espo/Core/Mail/Account/FetchData.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/Espo/Core/Mail/Account/FetchData.php b/application/Espo/Core/Mail/Account/FetchData.php index 245975981f..7b48fbe223 100644 --- a/application/Espo/Core/Mail/Account/FetchData.php +++ b/application/Espo/Core/Mail/Account/FetchData.php @@ -63,14 +63,14 @@ class FetchData { $value = $this->data->lastDate->$folder ?? null; - if ($value !== null && !is_string($value)) { - throw new RuntimeException("Bad value in fetch-data."); - } - if ($value === null) { return null; } + if (!is_string($value)) { + throw new RuntimeException("Bad value in fetch-data."); + } + return DateTime::fromString($value); } @@ -88,19 +88,19 @@ class FetchData $this->data->lastUID->$folder = $uniqueId; } - public function setLastDate(string $folder, ?DateTime $dateTime): void + public function setLastDate(string $folder, ?DateTime $lastDate): void { if (!property_exists($this->data, 'lastDate')) { $this->data->lastDate = (object) []; } - if ($dateTime === null) { + if ($lastDate === null) { $this->data->lastDate->$folder = null; return; } - $this->data->lastDate->$folder = $dateTime->getString(); + $this->data->lastDate->$folder = $lastDate->getString(); } public function setForceByDate(string $folder, bool $forceByDate): void