mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Refactors "strpos" and "substr" calls to improve code readability
Signed-off-by: Hamid Dehnavi <hamid.dev.pro@gmail.com>
This commit is contained in:
parent
f934d23cf2
commit
11447334e5
3 changed files with 7 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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://'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 . '/';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue