diff options
author | Hamid Dehnavi <hamid.dev.pro@gmail.com> | 2023-07-07 04:54:20 +0330 |
---|---|---|
committer | Hamid Dehnavi <hamid.dev.pro@gmail.com> | 2023-07-07 04:54:20 +0330 |
commit | d0b20534b94d0295472ab22157a2bc4c2c9fb703 (patch) | |
tree | 11778f60be448d4a2eb9e0d66d2cd1a164898c01 /lib/private/Files | |
parent | 56402460121080cb0d63e4c4d4ec51e5b409fed2 (diff) | |
download | nextcloud-server-d0b20534b94d0295472ab22157a2bc4c2c9fb703.tar.gz nextcloud-server-d0b20534b94d0295472ab22157a2bc4c2c9fb703.zip |
Refactor "substr" calls to improve code readability
Signed-off-by: Hamid Dehnavi <hamid.dev.pro@gmail.com>
Diffstat (limited to 'lib/private/Files')
-rw-r--r-- | lib/private/Files/Storage/DAV.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Storage/Local.php | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 70f22a17034..2d2bb52635b 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -120,9 +120,9 @@ class DAV extends Common { if (isset($params['host']) && isset($params['user']) && isset($params['password'])) { $host = $params['host']; //remove leading http[s], will be generated in createBaseUri() - if (substr($host, 0, 8) == "https://") { + if (str_starts_with($host, "https://")) { $host = substr($host, 8); - } elseif (substr($host, 0, 7) == "http://") { + } elseif (str_starts_with($host, "http://")) { $host = substr($host, 7); } $this->host = $host; diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index c0ce0e7021a..5515f5b1564 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -85,7 +85,7 @@ class Local extends \OC\Files\Storage\Common { $realPath = realpath($this->datadir) ?: $this->datadir; $this->realDataDir = rtrim($realPath, '/') . '/'; } - if (substr($this->datadir, -1) !== '/') { + if (!str_ends_with($this->datadir, '/')) { $this->datadir .= '/'; } $this->dataDirLength = strlen($this->realDataDir); @@ -155,7 +155,7 @@ class Local extends \OC\Files\Storage\Common { } public function is_dir($path) { - if (substr($path, -1) == '/') { + if (str_ends_with($path, '/')) { $path = substr($path, 0, -1); } return is_dir($this->getSourcePath($path)); |