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
|
|
|
{
|
2023-10-16 02:58:03 +02:00
|
|
|
public const ITUNES_NS = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
|
|
|
|
|
2019-10-31 19:00:12 +01:00
|
|
|
const MIME_TYPE = 'text/plain';
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2024-08-08 03:43:26 +02:00
|
|
|
protected array $feed = [];
|
2023-09-25 21:18:48 +02:00
|
|
|
protected array $items = [];
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2024-08-08 03:43:26 +02:00
|
|
|
protected int $lastModified;
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2024-08-23 17:34:06 +02:00
|
|
|
abstract public function render(): string;
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2024-01-09 20:18:33 +01:00
|
|
|
public function setFeed(array $feed)
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
2024-01-09 20:18:33 +01:00
|
|
|
$default = [
|
|
|
|
'name' => '',
|
|
|
|
'uri' => '',
|
|
|
|
'icon' => '',
|
|
|
|
'donationUri' => '',
|
|
|
|
];
|
|
|
|
$this->feed = array_merge($default, $feed);
|
2016-09-10 20:41:11 +02:00
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2024-01-09 20:18:33 +01:00
|
|
|
public function getFeed(): array
|
2018-08-26 00:00:38 +05:00
|
|
|
{
|
2024-01-09 20:18:33 +01:00
|
|
|
return $this->feed;
|
2018-08-26 00:00:38 +05:00
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2023-10-13 11:24:22 +02:00
|
|
|
public function setItems(array $items): void
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
2024-08-08 03:43:26 +02:00
|
|
|
foreach ($items as $item) {
|
|
|
|
$this->items[] = FeedItem::fromArray($item);
|
|
|
|
}
|
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
|
|
|
|
2024-01-09 20:18:33 +01:00
|
|
|
public function getMimeType(): string
|
2016-09-10 20:41:11 +02:00
|
|
|
{
|
2024-01-09 20:18:33 +01:00
|
|
|
return static::MIME_TYPE;
|
2016-09-10 20:41:11 +02:00
|
|
|
}
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2024-01-09 20:18:33 +01:00
|
|
|
public function setLastModified(int $lastModified)
|
|
|
|
{
|
|
|
|
$this->lastModified = $lastModified;
|
2016-09-10 20:41:11 +02:00
|
|
|
}
|
2016-09-05 18:05:19 +02:00
|
|
|
}
|