Skip to content

Commit

Permalink
Refactor "substr" calls to improve code readability
Browse files Browse the repository at this point in the history
Signed-off-by: Hamid Dehnavi <[email protected]>
  • Loading branch information
shdehnavi committed Jul 7, 2023
1 parent 5640246 commit 6526bab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private function transferIncomingShares(string $sourceUid,
$progress = new ProgressBar($output, count($sourceShares));
$prefix = "$destinationUid/files";
$finalShareTarget = '';
if (substr($finalTarget, 0, strlen($prefix)) === $prefix) {
if (str_starts_with($finalTarget, $prefix)) {
$finalShareTarget = substr($finalTarget, strlen($prefix));
}
foreach ($sourceShares as $share) {
Expand All @@ -457,7 +457,7 @@ private function transferIncomingShares(string $sourceUid,
if (trim($path, '/') !== '') {
$pathToCheck = '/' . trim($path) . '/';
}
if (substr($share->getTarget(), 0, strlen($pathToCheck)) !== $pathToCheck) {
if (!str_starts_with($share->getTarget(), $pathToCheck)) {
continue;
}
$shareTarget = $share->getTarget();
Expand Down

0 comments on commit 6526bab

Please sign in to comment.