diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-06-22 12:05:26 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-06-22 16:11:42 +0200 |
commit | 812016d62614ac3669a3fdf51fa2e07170e08c08 (patch) | |
tree | 1d67fcb259fae084881e50741ea6d7a5beb3e648 /lib/public | |
parent | b282fe1e6f5587a6440d170df245ad5acb8dc976 (diff) | |
download | nextcloud-server-812016d62614ac3669a3fdf51fa2e07170e08c08.tar.gz nextcloud-server-812016d62614ac3669a3fdf51fa2e07170e08c08.zip |
Cleanup avatar related code
- Move event listener to new event handling
- Add typing almost everywhere
- Fix inconsistent interface parameter
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/IAvatar.php | 39 | ||||
-rw-r--r-- | lib/public/User/Events/UserChangedEvent.php | 10 |
2 files changed, 24 insertions, 25 deletions
diff --git a/lib/public/IAvatar.php b/lib/public/IAvatar.php index 218ef258250..e4a9ce5dcc1 100644 --- a/lib/public/IAvatar.php +++ b/lib/public/IAvatar.php @@ -36,66 +36,71 @@ use OCP\Files\SimpleFS\ISimpleFile; interface IAvatar { /** - * get the users avatar + * Get the users avatar + * * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image * @return false|\OCP\IImage containing the avatar or false if there's no image * @since 6.0.0 - size of -1 was added in 9.0.0 */ - public function get($size = 64); + public function get(int $size = 64); /** * Check if an avatar exists for the user * - * @return bool * @since 8.1.0 */ - public function exists(); + public function exists(): bool; /** * Check if the avatar of a user is a custom uploaded one * - * @return bool * @since 14.0.0 */ public function isCustomAvatar(): bool; /** - * sets the users avatar + * Sets the users avatar + * * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar * @throws \Exception if the provided file is not a jpg or png image * @throws \Exception if the provided image is not valid * @throws \OC\NotSquareException if the image is not square - * @return void * @since 6.0.0 */ - public function set($data); + public function set($data): void; /** - * remove the users avatar - * @return void + * Remove the user's avatar + * + * @param bool $silent Whether removing the avatar should trigger a change * @since 6.0.0 */ - public function remove(); + public function remove(bool $silent = false): void; /** * Get the file of the avatar - * @param int $size -1 can be used to not scale the image - * @return ISimpleFile + * + * @param int $size The desired image size. -1 can be used to not scale the image * @throws NotFoundException * @since 9.0.0 */ - public function getFile($size); + public function getFile(int $size): ISimpleFile; /** - * @param string $text + * Get the avatar background color + * * @return Color Object containting r g b int in the range [0, 255] * @since 14.0.0 */ public function avatarBackgroundColor(string $text); /** - * Handle a changed user + * Updates the display name if changed. + * + * @param string $feature The changed feature + * @param mixed $oldValue The previous value + * @param mixed $newValue The new value * @since 13.0.0 */ - public function userChanged($feature, $oldValue, $newValue); + public function userChanged(string $feature, $oldValue, $newValue): void; } diff --git a/lib/public/User/Events/UserChangedEvent.php b/lib/public/User/Events/UserChangedEvent.php index 3a40f8c3f11..f48dd3914e6 100644 --- a/lib/public/User/Events/UserChangedEvent.php +++ b/lib/public/User/Events/UserChangedEvent.php @@ -32,16 +32,10 @@ use OCP\IUser; * @since 18.0.0 */ class UserChangedEvent extends Event { - - /** @var IUser */ - private $user; - - /** @var string */ - private $feature; - + private IUser $user; + private string $feature; /** @var mixed */ private $value; - /** @var mixed */ private $oldValue; |