Skip to content

Commit f8e0a4a

Browse files
committed
refactor: simplify expiration date handling in share methods
- Remove redundant if/else checks since getExpirationDate() returns null - Add setExpirationDate() in createShare() to reflect auto-applied expiry dates Signed-off-by: Silver <s.szmajduch@posteo.de>
1 parent 09f9a10 commit f8e0a4a

1 file changed

Lines changed: 5 additions & 21 deletions

File tree

lib/Service/CollectiveShareService.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ public function findShare(string $userId, int $collectiveId, int $pageId): ?Coll
125125
$collectiveShare->setPassword($folderShare->getPassword());
126126
}
127127

128-
if ($folderShare->getExpirationDate()) {
129-
$collectiveShare->setExpirationDate($folderShare->getExpirationDate());
130-
} else {
131-
$collectiveShare->setExpirationDate(null);
132-
}
128+
$collectiveShare->setExpirationDate($folderShare->getExpirationDate());
133129
return $collectiveShare;
134130
}
135131

@@ -157,11 +153,7 @@ public function findShareByToken(string $token, bool $getPermissionInfo = true):
157153
$collectiveShare->setPassword($folderShare->getPassword());
158154
}
159155

160-
if ($folderShare->getExpirationDate()) {
161-
$collectiveShare->setExpirationDate($folderShare->getExpirationDate());
162-
} else {
163-
$collectiveShare->setExpirationDate(null);
164-
}
156+
$collectiveShare->setExpirationDate($folderShare->getExpirationDate());
165157
return $collectiveShare;
166158
}
167159

@@ -181,12 +173,7 @@ public function getSharesByCollectiveAndUser(string $userId, int $collectiveId):
181173
$share->setPassword($folderShare->getPassword());
182174
}
183175

184-
$expirationDate = $folderShare->getExpirationDate();
185-
if ($expirationDate) {
186-
$share->setExpirationDate($expirationDate);
187-
} else {
188-
$share->setExpirationDate(null);
189-
}
176+
$share->setExpirationDate($folderShare->getExpirationDate());
190177
$shares[] = $share;
191178
}
192179

@@ -238,6 +225,7 @@ public function createShare(string $userId, Collective $collective, ?PageInfo $p
238225
if ($password != '') {
239226
$collectiveShare->setPassword($folderShare->getPassword());
240227
}
228+
$collectiveShare->setExpirationDate($folderShare->getExpirationDate());
241229
return $collectiveShare;
242230
}
243231

@@ -297,11 +285,7 @@ public function updateShare(string $userId, Collective $collective, ?PageInfo $p
297285
$share->setEditable($this->isShareEditable($folderShare));
298286
$share->setPassword($folderShare->getPassword() ?? '');
299287

300-
if ($folderShare->getExpirationDate()) {
301-
$share->setExpirationDate($folderShare->getExpirationDate());
302-
} else {
303-
$share->setExpirationDate(null);
304-
}
288+
$share->setExpirationDate($folderShare->getExpirationDate());
305289

306290
return $share;
307291
}

0 commit comments

Comments
 (0)