63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
namespace Uiharu\Lookup;
|
|
|
|
use Uiharu\Colour;
|
|
use Uiharu\Url;
|
|
use Index\MediaType;
|
|
|
|
class WebLookupSiteResult extends WebLookupResult {
|
|
private object $siteInfo;
|
|
|
|
public function __construct(Url $url, MediaType $mediaType, object $siteInfo) {
|
|
parent::__construct($url, $mediaType);
|
|
$this->siteInfo = $siteInfo;
|
|
}
|
|
|
|
public function getObjectType(): string {
|
|
return $this->siteInfo->type;
|
|
}
|
|
|
|
public function hasColour(): bool {
|
|
return !empty($this->siteInfo->colour);
|
|
}
|
|
public function getColour(): int {
|
|
return Colour::convertFromCSS($this->siteInfo->colour);
|
|
}
|
|
|
|
public function hasTitle(): bool {
|
|
return true;
|
|
}
|
|
public function getTitle(): string {
|
|
if(!empty($this->siteInfo->metaTitle))
|
|
return $this->siteInfo->metaTitle;
|
|
if(!empty($this->siteInfo->title))
|
|
return $this->siteInfo->title;
|
|
return $this->siteInfo->siteName;
|
|
}
|
|
|
|
public function hasSiteName(): bool {
|
|
return !empty($this->siteInfo->siteName);
|
|
}
|
|
public function getSiteName(): string {
|
|
return $this->siteInfo->siteName;
|
|
}
|
|
|
|
public function hasDescription(): bool {
|
|
return !empty($this->siteInfo->desc);
|
|
}
|
|
public function getDescription(): string {
|
|
return $this->siteInfo->desc;
|
|
}
|
|
|
|
public function hasPreviewImage(): bool {
|
|
return !empty($this->siteInfo->image);
|
|
}
|
|
public function getPreviewImage(): string {
|
|
return $this->siteInfo->image;
|
|
}
|
|
|
|
public function getWebSiteInfo(): object {
|
|
return $this->siteInfo;
|
|
}
|
|
}
|