From 69319c07bad5f4f301045a32bcabab8d2daaea57 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 21 Jan 2025 10:14:36 +0600 Subject: [PATCH] pkp/pkp-lib#10668 code cleanup --- classes/announcement/Announcement.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/announcement/Announcement.php b/classes/announcement/Announcement.php index 398b55493f9..f6a780f477f 100644 --- a/classes/announcement/Announcement.php +++ b/classes/announcement/Announcement.php @@ -119,7 +119,7 @@ public function save(array $options = []) Hook::call('Announcement::add', [$this]); - $hasNewImage = isset($this?->image?->temporaryFileId) ? $this->image->temporaryFileId : null; + $hasNewImage = $this?->image?->temporaryFileId ?? null; // if announcement is being inserted and includes new image, upload it if ($newlyCreated) { @@ -135,7 +135,7 @@ public function save(array $options = []) $this->handleImageUpload(); } - // If there is no new image and image data exists in DB and it's now removed + // If there is no new image and image data exists in DB and it's now removed as part of update // need to delete the image for this announcement model instance if (!$hasNewImage && !$this?->image && $this->fresh()->image) { $this->deleteImage(); @@ -290,7 +290,7 @@ protected function imageUrl(bool $withTimestamp = true): Attribute protected function imageAltText(): Attribute { return Attribute::make( - get: fn () => isset($this->image?->altText) ? $this->image->altText : '' + get: fn () => $this->image?->altText ?? '' ); } @@ -363,7 +363,7 @@ protected function getImageData(TemporaryFile $temporaryFile): array 'name' => $temporaryFile->getOriginalFileName(), 'uploadName' => $this->getImageFilename($temporaryFile), 'dateUploaded' => Core::getCurrentDate(), - 'altText' => isset($image->altText) ? $image->altText : '', + 'altText' => $image->altText ?? '', ]; }