rss-bridge/lib/FormatAbstract.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2023-09-25 21:18:48 +02:00
abstract class FormatAbstract
{
const MIME_TYPE = 'text/plain';
2023-09-25 21:18:48 +02:00
protected string $charset = 'UTF-8';
protected array $items = [];
protected int $lastModified;
protected array $extraInfos = [];
2023-09-25 21:18:48 +02:00
abstract public function stringify();
2023-09-25 21:18:48 +02:00
public function getMimeType(): string
{
return static::MIME_TYPE;
}
2023-09-25 21:18:48 +02:00
public function setCharset(string $charset)
{
$this->charset = $charset;
}
2023-09-25 21:18:48 +02:00
public function getCharset(): string
{
2023-09-25 21:18:48 +02:00
return $this->charset;
}
2023-09-25 21:18:48 +02:00
public function setLastModified(int $lastModified)
{
$this->lastModified = $lastModified;
}
public function setItems(array $items)
{
$this->items = $items;
}
2023-09-25 21:18:48 +02:00
/**
* @return FeedItem[] The items
*/
public function getItems(): array
{
return $this->items;
}
2023-09-25 21:18:48 +02:00
public function setExtraInfos(array $infos = [])
{
2023-09-25 21:18:48 +02:00
$extras = [
'name',
'uri',
'icon',
'donationUri',
];
foreach ($extras as $extra) {
if (!isset($infos[$extra])) {
$infos[$extra] = '';
}
}
2023-09-25 21:18:48 +02:00
$this->extraInfos = $infos;
}
2023-09-25 21:18:48 +02:00
public function getExtraInfos(): array
{
2023-09-25 21:18:48 +02:00
if (!$this->extraInfos) {
$this->setExtraInfos();
}
return $this->extraInfos;
}
}