Refactors "strpos" calls in /apps/files_external to improve code readability.

Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
pull/38619/head
Faraz Samapoor 3 years ago
parent 2188505837
commit cfb921b26c
  1. 2
      apps/files_external/lib/Command/Create.php
  2. 4
      apps/files_external/lib/Lib/Storage/FtpConnection.php
  3. 2
      apps/files_external/lib/Lib/Storage/OwnCloud.php
  4. 2
      apps/files_external/lib/Lib/Storage/SFTP.php
  5. 10
      apps/files_external/lib/Lib/Storage/SMB.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;
}

@ -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;

@ -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 .= '/';
}

@ -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;
}

@ -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];
}
/**

Loading…
Cancel
Save