2016-09-05 18:05:19 +02:00
|
|
|
<?php
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
abstract class FormatAbstract
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
2019-10-31 19:00:12 +01:00
|
|
|
const MIME_TYPE = 'text/plain';
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
protected string $charset = 'UTF-8';
|
|
|
|
protected array $items = [];
|
|
|
|
protected int $lastModified;
|
|
|
|
protected array $extraInfos = [];
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
abstract public function stringify();
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
public function getMimeType(): string
|
2019-10-31 19:00:12 +01:00
|
|
|
{
|
|
|
|
return static::MIME_TYPE;
|
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
public function setCharset(string $charset)
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
|
|
|
$this->charset = $charset;
|
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
public function getCharset(): string
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
2023-09-25 21:18:48 +02:00
|
|
|
return $this->charset;
|
2016-09-10 20:41:11 +02:00
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
public function setLastModified(int $lastModified)
|
2018-08-26 00:00:38 +05:00
|
|
|
{
|
|
|
|
$this->lastModified = $lastModified;
|
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-10-13 11:24:22 +02:00
|
|
|
/**
|
|
|
|
* @param FeedItem[] $items
|
|
|
|
*/
|
|
|
|
public function setItems(array $items): void
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
2018-12-26 22:41:32 +01:00
|
|
|
$this->items = $items;
|
2016-09-10 20:41:11 +02:00
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
/**
|
|
|
|
* @return FeedItem[] The items
|
|
|
|
*/
|
|
|
|
public function getItems(): array
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
|
|
|
return $this->items;
|
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
public function setExtraInfos(array $infos = [])
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
2023-09-25 21:18:48 +02:00
|
|
|
$extras = [
|
|
|
|
'name',
|
|
|
|
'uri',
|
|
|
|
'icon',
|
|
|
|
'donationUri',
|
|
|
|
];
|
|
|
|
foreach ($extras as $extra) {
|
|
|
|
if (!isset($infos[$extra])) {
|
|
|
|
$infos[$extra] = '';
|
2016-09-10 20:41:11 +02:00
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
}
|
2023-09-25 21:18:48 +02:00
|
|
|
$this->extraInfos = $infos;
|
2016-09-10 20:41:11 +02:00
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-09-25 21:18:48 +02:00
|
|
|
public function getExtraInfos(): array
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
2023-09-25 21:18:48 +02:00
|
|
|
if (!$this->extraInfos) {
|
|
|
|
$this->setExtraInfos();
|
2016-09-10 20:41:11 +02:00
|
|
|
}
|
|
|
|
return $this->extraInfos;
|
|
|
|
}
|
2016-09-05 18:05:19 +02:00
|
|
|
}
|