seria/src/SiteInfo.php

39 lines
1 KiB
PHP

<?php
namespace Seria;
use Syokuhou\IConfig;
use Seria\Users\UserInfo;
class SiteInfo {
public function __construct(private IConfig $config) {}
public function getName(): string {
return $this->config->getString('name');
}
public function getHost(): string {
return $this->config->getString('host');
}
public function getMainSiteName(): string {
return $this->config->getString('parent');
}
public function getLoginUrl(): string {
return $this->config->getString('login');
}
public function getProfileUrl(UserInfo|string $userInfo): string {
if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId();
return sprintf($this->config->getString('profile'), $userInfo);
}
public function getAvatarUrl(UserInfo|string $userInfo, int $res = 0): string {
if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId();
return sprintf($this->config->getString($res < 1 ? 'avatar' : 'avatar:res'), $userInfo, $res);
}
}