aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorFaraz Samapoor <f.samapoor@gmail.com>2023-06-02 19:54:49 +0330
committerFaraz Samapoor <f.samapoor@gmail.com>2023-06-02 19:54:49 +0330
commitcfb921b26c656352f727b3903b8961e1c48a8051 (patch)
tree278ae45067be1611967e7f3135d9767213eb1d1a /apps/files_external
parent21885058378c1fb15ad0cb847043c0eea0e7de22 (diff)
downloadnextcloud-server-cfb921b26c656352f727b3903b8961e1c48a8051.tar.gz
nextcloud-server-cfb921b26c656352f727b3903b8961e1c48a8051.zip
Refactors "strpos" calls in /apps/files_external to improve code readability.
Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/Command/Create.php2
-rw-r--r--apps/files_external/lib/Lib/Storage/FtpConnection.php4
-rw-r--r--apps/files_external/lib/Lib/Storage/OwnCloud.php2
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php2
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php10
5 files changed, 11 insertions, 9 deletions
diff --git a/apps/files_external/lib/Command/Create.php b/apps/files_external/lib/Command/Create.php
index 17e4731a2d6..6208ac0da07 100644
--- a/apps/files_external/lib/Command/Create.php
+++ b/apps/files_external/lib/Command/Create.php
@@ -134,7 +134,7 @@ class Create extends Base {
$config = [];
foreach ($configInput as $configOption) {
- if (!strpos($configOption, '=')) {
+ if (!str_contains($configOption, '=')) {
$output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
return 1;
}
diff --git a/apps/files_external/lib/Lib/Storage/FtpConnection.php b/apps/files_external/lib/Lib/Storage/FtpConnection.php
index f183a5a52de..cca03ddda65 100644
--- a/apps/files_external/lib/Lib/Storage/FtpConnection.php
+++ b/apps/files_external/lib/Lib/Storage/FtpConnection.php
@@ -110,7 +110,7 @@ class FtpConnection {
public function nlist(string $path) {
$files = @ftp_nlist($this->connection, $path);
return array_map(function ($name) {
- if (strpos($name, '/') !== false) {
+ if (str_contains($name, '/')) {
$name = basename($name);
}
return $name;
@@ -122,7 +122,7 @@ class FtpConnection {
if ($files !== false) {
return array_map(function ($file) {
- if (strpos($file['name'], '/') !== false) {
+ if (str_contains($file['name'], '/')) {
$file['name'] = basename($file['name']);
}
return $file;
diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php
index d5926008f62..ba7ae1c36a9 100644
--- a/apps/files_external/lib/Lib/Storage/OwnCloud.php
+++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php
@@ -60,7 +60,7 @@ class OwnCloud extends \OC\Files\Storage\DAV implements IDisableEncryptionStorag
$host = substr($host, 0, $hostSlashPos);
}
- if (substr($contextPath, -1) !== '/') {
+ if (!str_ends_with($contextPath, '/')) {
$contextPath .= '/';
}
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index e46f60d0be4..532c50808db 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -63,7 +63,7 @@ class SFTP extends \OC\Files\Storage\Common {
*/
private function splitHost($host) {
$input = $host;
- if (strpos($host, '://') === false) {
+ if (!str_contains($host, '://')) {
// add a protocol to fix parse_url behavior with ipv6
$host = 'http://' . $host;
}
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index e0e4659e668..a022a051e20 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -139,13 +139,15 @@ class SMB extends Common implements INotifyStorage {
}
private function splitUser($user) {
- if (strpos($user, '/')) {
+ if (str_contains($user, '/')) {
return explode('/', $user, 2);
- } elseif (strpos($user, '\\')) {
+ }
+
+ if (str_contains($user, '\\')) {
return explode('\\', $user);
- } else {
- return [null, $user];
}
+
+ return [null, $user];
}
/**