avatarFunction($login, User::AVATAR_SIZE_SMALL); } public function avatarMediumFunction(string $login): string { return $this->avatarFunction($login, User::AVATAR_SIZE_MEDIUM); } public function avatarLargeFunction(string $login): string { return $this->avatarFunction($login, User::AVATAR_SIZE_LARGE); } public function avatarFunction(string $login, $size): string { return $this->getAvatarUrlByLogin($login, $size); } public function userUrl(string $login): string { return sprintf('%s://%s.%s/', $this->pointScheme, $login, $this->pointDomain); } public function userBlogUrl(string $login): string { return sprintf('%s://%s.%s/blog/', $this->pointScheme, $login, $this->pointDomain); } public function postUrl(string $postId): string { return sprintf('%s://%s/%s', $this->pointScheme, $this->pointDomain, $postId); } private function getAvatarUrlByLogin(string $login, string $size): string { if (!in_array($size, [User::AVATAR_SIZE_SMALL, User::AVATAR_SIZE_MEDIUM, User::AVATAR_SIZE_LARGE], true)) { throw new \InvalidArgumentException('Avatar size must be one of restricted variants. See User::AVATAR_SIZE_* constants.'); } return sprintf('%s://%s/avatar/%s/%s', $this->pointScheme, $this->pointDomain, urlencode($login), $size); } }