Browse Source

Refactors "strpos" and "substr" calls to improve code readability

Signed-off-by: Hamid Dehnavi <hamid.dev.pro@gmail.com>
tags/v28.0.0beta1
Hamid Dehnavi 1 year ago
parent
commit
11447334e5

+ 4
- 4
apps/federatedfilesharing/lib/AddressHandler.php View File

* @return string * @return string
*/ */
public function removeProtocolFromUrl($url) { public function removeProtocolFromUrl($url) {
if (strpos($url, 'https://') === 0) {
if (str_starts_with($url, 'https://')) {
return substr($url, strlen('https://')); return substr($url, strlen('https://'));
} elseif (strpos($url, 'http://') === 0) {
} elseif (str_starts_with($url, 'http://')) {
return substr($url, strlen('http://')); return substr($url, strlen('http://'));
} }


* @return bool * @return bool
*/ */
public function urlContainProtocol($url) { 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; return true;
} }



+ 2
- 2
apps/federatedfilesharing/lib/Notifier.php View File

protected function getDisplayName(ICloudId $cloudId): string { protected function getDisplayName(ICloudId $cloudId): string {
$server = $cloudId->getRemote(); $server = $cloudId->getRemote();
$user = $cloudId->getUser(); $user = $cloudId->getUser();
if (strpos($server, 'http://') === 0) {
if (str_starts_with($server, 'http://')) {
$server = substr($server, strlen('http://')); $server = substr($server, strlen('http://'));
} elseif (strpos($server, 'https://') === 0) {
} elseif (str_starts_with($server, 'https://')) {
$server = substr($server, strlen('https://')); $server = substr($server, strlen('https://'));
} }



+ 1
- 1
apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php View File

[$ownerUid, $remote] = $this->addressHandler->splitUserRemote($share->getOwner()); [$ownerUid, $remote] = $this->addressHandler->splitUserRemote($share->getOwner());
// for backward compatibility make sure that the remote url stored in the // for backward compatibility make sure that the remote url stored in the
// database ends with a trailing slash // database ends with a trailing slash
if (substr($remote, -1) !== '/') {
if (!str_ends_with($remote, '/')) {
$remote = $remote . '/'; $remote = $remote . '/';
} }



Loading…
Cancel
Save