diff options
Diffstat (limited to 'apps/dav/lib/Avatars')
-rw-r--r-- | apps/dav/lib/Avatars/AvatarHome.php | 41 | ||||
-rw-r--r-- | apps/dav/lib/Avatars/AvatarNode.php | 42 | ||||
-rw-r--r-- | apps/dav/lib/Avatars/RootCollection.php | 29 |
3 files changed, 27 insertions, 85 deletions
diff --git a/apps/dav/lib/Avatars/AvatarHome.php b/apps/dav/lib/Avatars/AvatarHome.php index ba52daeb2b3..c3b95db1f4f 100644 --- a/apps/dav/lib/Avatars/AvatarHome.php +++ b/apps/dav/lib/Avatars/AvatarHome.php @@ -1,26 +1,9 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud GmbH - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @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: 2017-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2017 ownCloud GmbH + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\DAV\Avatars; @@ -33,20 +16,16 @@ use Sabre\Uri; class AvatarHome implements ICollection { - /** @var array */ - private $principalInfo; - /** @var IAvatarManager */ - private $avatarManager; - /** * AvatarHome constructor. * * @param array $principalInfo * @param IAvatarManager $avatarManager */ - public function __construct($principalInfo, IAvatarManager $avatarManager) { - $this->principalInfo = $principalInfo; - $this->avatarManager = $avatarManager; + public function __construct( + private $principalInfo, + private IAvatarManager $avatarManager, + ) { } public function createFile($name, $data = null) { @@ -59,8 +38,8 @@ class AvatarHome implements ICollection { public function getChild($name) { $elements = pathinfo($name); - $ext = isset($elements['extension']) ? $elements['extension'] : ''; - $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64'); + $ext = $elements['extension'] ?? ''; + $size = (int)($elements['filename'] ?? '64'); if (!in_array($ext, ['jpeg', 'png'], true)) { throw new MethodNotAllowed('File format not allowed'); } diff --git a/apps/dav/lib/Avatars/AvatarNode.php b/apps/dav/lib/Avatars/AvatarNode.php index ade523561f2..b3a605fbb02 100644 --- a/apps/dav/lib/Avatars/AvatarNode.php +++ b/apps/dav/lib/Avatars/AvatarNode.php @@ -1,24 +1,9 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud GmbH - * - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @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: 2017-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2017 ownCloud GmbH + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\DAV\Avatars; @@ -26,10 +11,6 @@ use OCP\IAvatar; use Sabre\DAV\File; class AvatarNode extends File { - private $ext; - private $size; - private $avatar; - /** * AvatarNode constructor. * @@ -37,10 +18,11 @@ class AvatarNode extends File { * @param string $ext * @param IAvatar $avatar */ - public function __construct($size, $ext, $avatar) { - $this->size = $size; - $this->ext = $ext; - $this->avatar = $avatar; + public function __construct( + private $size, + private $ext, + private $avatar, + ) { } /** @@ -87,10 +69,6 @@ class AvatarNode extends File { } public function getLastModified() { - $timestamp = $this->avatar->getFile($this->size)->getMTime(); - if (!empty($timestamp)) { - return (int)$timestamp; - } - return $timestamp; + return $this->avatar->getFile($this->size)->getMTime(); } } diff --git a/apps/dav/lib/Avatars/RootCollection.php b/apps/dav/lib/Avatars/RootCollection.php index c5e78624d44..033dcaf7a5c 100644 --- a/apps/dav/lib/Avatars/RootCollection.php +++ b/apps/dav/lib/Avatars/RootCollection.php @@ -1,29 +1,14 @@ <?php + /** - * @copyright Copyright (c) 2016 Thomas Müller <thomas.mueller@tmit.eu> - * - * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * 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 - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2017 ownCloud GmbH + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\DAV\Avatars; +use OCP\IAvatarManager; +use OCP\Server; use Sabre\DAVACL\AbstractPrincipalCollection; class RootCollection extends AbstractPrincipalCollection { @@ -39,7 +24,7 @@ class RootCollection extends AbstractPrincipalCollection { * @return AvatarHome */ public function getChildForPrincipal(array $principalInfo) { - $avatarManager = \OC::$server->getAvatarManager(); + $avatarManager = Server::get(IAvatarManager::class); return new AvatarHome($principalInfo, $avatarManager); } |