diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2023-09-27 20:32:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-27 20:32:19 +0200 |
commit | bcda3314edce707568ed70f3add43c82304171d4 (patch) | |
tree | 62dcd350f982948bede87c7e5aad30e592c1a65d /apps | |
parent | dd3cd29224cd93c6168cd42e93e68cdd6ac5e921 (diff) | |
parent | 11447334e55a6c4b0673d74851ffee4f81d54284 (diff) | |
download | nextcloud-server-bcda3314edce707568ed70f3add43c82304171d4.tar.gz nextcloud-server-bcda3314edce707568ed70f3add43c82304171d4.zip |
Merge pull request #39213 from shdehnavi/replace_strpos_and_substr_calls_in_federatedfilesharing_app
Refactor "strpos" and "substr" calls in federatedfilesharing app to improve code readability
Diffstat (limited to 'apps')
-rw-r--r-- | apps/federatedfilesharing/lib/AddressHandler.php | 8 | ||||
-rw-r--r-- | apps/federatedfilesharing/lib/Notifier.php | 4 | ||||
-rw-r--r-- | apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php index 66af86b9159..ae9ff9be34b 100644 --- a/apps/federatedfilesharing/lib/AddressHandler.php +++ b/apps/federatedfilesharing/lib/AddressHandler.php @@ -130,9 +130,9 @@ class AddressHandler { * @return string */ public function removeProtocolFromUrl($url) { - if (strpos($url, 'https://') === 0) { + if (str_starts_with($url, 'https://')) { return substr($url, strlen('https://')); - } elseif (strpos($url, 'http://') === 0) { + } elseif (str_starts_with($url, 'http://')) { return substr($url, strlen('http://')); } @@ -146,8 +146,8 @@ class AddressHandler { * @return bool */ public function urlContainProtocol($url) { - if (strpos($url, 'https://') === 0 || - strpos($url, 'http://') === 0) { + if (str_starts_with($url, 'https://') || + str_starts_with($url, 'http://')) { return true; } diff --git a/apps/federatedfilesharing/lib/Notifier.php b/apps/federatedfilesharing/lib/Notifier.php index 563b121ce5b..ffbc3868a3a 100644 --- a/apps/federatedfilesharing/lib/Notifier.php +++ b/apps/federatedfilesharing/lib/Notifier.php @@ -202,9 +202,9 @@ class Notifier implements INotifier { protected function getDisplayName(ICloudId $cloudId): string { $server = $cloudId->getRemote(); $user = $cloudId->getUser(); - if (strpos($server, 'http://') === 0) { + if (str_starts_with($server, 'http://')) { $server = substr($server, strlen('http://')); - } elseif (strpos($server, 'https://') === 0) { + } elseif (str_starts_with($server, 'https://')) { $server = substr($server, strlen('https://')); } diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index 5d6a11c2ffd..923214f0f2d 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -116,7 +116,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { [$ownerUid, $remote] = $this->addressHandler->splitUserRemote($share->getOwner()); // for backward compatibility make sure that the remote url stored in the // database ends with a trailing slash - if (substr($remote, -1) !== '/') { + if (!str_ends_with($remote, '/')) { $remote = $remote . '/'; } |