From: Tim Düsterhus Date: Wed, 17 Feb 2021 14:49:23 +0000 (+0100) Subject: Add AvatarDecorator X-Git-Tag: 5.4.0_Alpha_1~238^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3e48a1a1c3cf91fab45fc976c80ba70a48710263;p=GitHub%2FWoltLab%2FWCF.git Add AvatarDecorator --- 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(); + } +}