aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing
diff options
context:
space:
mode:
authorHamid Dehnavi <hamid.dev.pro@gmail.com>2023-07-07 04:29:25 +0330
committerFaraz Samapoor <f.samapoor@gmail.com>2023-09-27 20:37:51 +0330
commit11447334e55a6c4b0673d74851ffee4f81d54284 (patch)
tree1cf284be07de2c78c92e66fed1b063b09d230017 /apps/federatedfilesharing
parentf934d23cf2a1b5446f38c8569fef5b1346130daf (diff)
downloadnextcloud-server-11447334e55a6c4b0673d74851ffee4f81d54284.tar.gz
nextcloud-server-11447334e55a6c4b0673d74851ffee4f81d54284.zip
Refactors "strpos" and "substr" calls to improve code readability
Signed-off-by: Hamid Dehnavi <hamid.dev.pro@gmail.com>
Diffstat (limited to 'apps/federatedfilesharing')
-rw-r--r--apps/federatedfilesharing/lib/AddressHandler.php8
-rw-r--r--apps/federatedfilesharing/lib/Notifier.php4
-rw-r--r--apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php2
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 . '/';
}