aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib/AddressHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federatedfilesharing/lib/AddressHandler.php')
-rw-r--r--apps/federatedfilesharing/lib/AddressHandler.php64
1 files changed, 17 insertions, 47 deletions
diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php
index 3a48e2adc86..4588e6da288 100644
--- a/apps/federatedfilesharing/lib/AddressHandler.php
+++ b/apps/federatedfilesharing/lib/AddressHandler.php
@@ -1,35 +1,17 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Bjoern Schiessle <bjoern@schiessle.org>
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCA\FederatedFileSharing;
-use OC\HintException;
use OCP\Federation\ICloudIdManager;
+use OCP\HintException;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\Util;
/**
* Class AddressHandler - parse, modify and construct federated sharing addresses
@@ -38,37 +20,25 @@ use OCP\IURLGenerator;
*/
class AddressHandler {
- /** @var IL10N */
- private $l;
-
- /** @var IURLGenerator */
- private $urlGenerator;
-
- /** @var ICloudIdManager */
- private $cloudIdManager;
-
/**
* AddressHandler constructor.
*
* @param IURLGenerator $urlGenerator
- * @param IL10N $il10n
+ * @param IL10N $l
* @param ICloudIdManager $cloudIdManager
*/
public function __construct(
- IURLGenerator $urlGenerator,
- IL10N $il10n,
- ICloudIdManager $cloudIdManager
+ private IURLGenerator $urlGenerator,
+ private IL10N $l,
+ private ICloudIdManager $cloudIdManager,
) {
- $this->l = $il10n;
- $this->urlGenerator = $urlGenerator;
- $this->cloudIdManager = $cloudIdManager;
}
/**
* split user and remote from federated cloud id
*
* @param string $address federated share address
- * @return array [user, remoteURL]
+ * @return array<string> [user, remoteURL]
* @throws HintException
*/
public function splitUserRemote($address) {
@@ -105,12 +75,12 @@ class AddressHandler {
if (rtrim($normalizedServer1, '/') === rtrim($normalizedServer2, '/')) {
// FIXME this should be a method in the user management instead
- \OCP\Util::emitHook(
+ Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$user1]
);
- \OCP\Util::emitHook(
+ Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$user2]
@@ -131,9 +101,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://'));
}
@@ -147,8 +117,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;
}