misuzu/src/SiteInfo.php

53 lines
1.1 KiB
PHP

<?php
namespace Misuzu;
use Syokuhou\IConfig;
class SiteInfo {
private bool $loaded = false;
private array $props;
public function __construct(
private IConfig $config
) {}
public function load(): void {
if($this->loaded)
return;
$this->loaded = true;
$this->props = $this->config->getValues([
['name:s', 'Misuzu'],
'desc:s',
'url:s',
'ext_logo:s',
]);
}
public function getName(): string {
$this->load();
return $this->props['name'];
}
public function getDescription(): string {
$this->load();
return $this->props['desc'];
}
public function hasURL(): bool {
return $this->getURL() !== '';
}
public function getURL(): string {
$this->load();
return rtrim($this->props['url'], '/');
}
public function hasExternalLogo(): bool {
return $this->getExternalLogo() !== '';
}
public function getExternalLogo(): string {
$this->load();
return $this->props['ext_logo'];
}
}