From 3e48a1a1c3cf91fab45fc976c80ba70a48710263 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 17 Feb 2021 15:49:23 +0100 Subject: [PATCH] Add AvatarDecorator --- .../user/avatar/AvatarDecorator.class.php | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 wcfsetup/install/files/lib/data/user/avatar/AvatarDecorator.class.php diff --git a/wcfsetup/install/files/lib/data/user/avatar/AvatarDecorator.class.php b/wcfsetup/install/files/lib/data/user/avatar/AvatarDecorator.class.php new file mode 100644 index 0000000000..21649bc0e0 --- /dev/null +++ b/wcfsetup/install/files/lib/data/user/avatar/AvatarDecorator.class.php @@ -0,0 +1,80 @@ + + * @package WoltLabSuite\Core\Data\User\Avatar + */ +final class AvatarDecorator implements IUserAvatar, ISafeFormatAvatar +{ + /** + * @var IUserAvatar + */ + private $avatar; + + public function __construct(IUserAvatar $avatar) + { + $this->avatar = $avatar; + } + + /** + * @inheritDoc + */ + public function getSafeURL(?int $size = null): string + { + if ($this->avatar instanceof ISafeFormatAvatar) { + return $this->avatar->getSafeURL($size); + } + + return $this->avatar->getURL($size); + } + + /** + * @inheritDoc + */ + public function getSafeImageTag(?int $size = null): string + { + if ($this->avatar instanceof ISafeFormatAvatar) { + return $this->avatar->getSafeImageTag($size); + } + + return $this->avatar->getImageTag($size); + } + + /** + * @inheritDoc + */ + public function getURL($size = null) + { + return $this->avatar->getURL(); + } + + /** + * @inheritDoc + */ + public function getImageTag($size = null) + { + return $this->avatar->getImageTag($size); + } + + /** + * @inheritDoc + */ + public function getWidth() + { + return $this->avatar->getWidth(); + } + + /** + * @inheritDoc + */ + public function getHeight() + { + return $this->avatar->getHeight(); + } +} -- 2.20.1