Made AvatarManager string and add return types

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-01-13 20:34:39 +01:00
parent c0c4263546
commit 4c56acffd1
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *
@ -29,6 +30,7 @@ namespace OC;
use OCP\Files\IAppData; use OCP\Files\IAppData;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\IAvatar;
use OCP\IAvatarManager; use OCP\IAvatarManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
@ -85,9 +87,9 @@ class AvatarManager implements IAvatarManager {
* @throws \Exception In case the username is potentially dangerous * @throws \Exception In case the username is potentially dangerous
* @throws NotFoundException In case there is no user folder yet * @throws NotFoundException In case there is no user folder yet
*/ */
public function getAvatar($userId) { public function getAvatar(string $userId) : IAvatar {
$user = $this->userManager->get($userId); $user = $this->userManager->get($userId);
if (is_null($user)) { if ($user === null) {
throw new \Exception('user does not exist'); throw new \Exception('user does not exist');
} }

View File

@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *
@ -35,12 +36,12 @@ interface IAvatarManager {
/** /**
* return a user specific instance of \OCP\IAvatar * return a user specific instance of \OCP\IAvatar
* @see \OCP\IAvatar * @see IAvatar
* @param string $user the ownCloud user id * @param string $user the ownCloud user id
* @return \OCP\IAvatar * @return IAvatar
* @throws \Exception In case the username is potentially dangerous * @throws \Exception In case the username is potentially dangerous
* @throws \OCP\Files\NotFoundException In case there is no user folder yet * @throws \OCP\Files\NotFoundException In case there is no user folder yet
* @since 6.0.0 * @since 6.0.0
*/ */
public function getAvatar($user); public function getAvatar(string $user) : IAvatar;
} }