2016-09-05 19:05:19 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2023-09-25 22:18:48 +03:00
|
|
|
abstract class FormatAbstract
|
2016-09-10 21:41:11 +03:00
|
|
|
{
|
2023-10-16 03:58:03 +03:00
|
|
|
public const ITUNES_NS = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
|
|
|
|
|
2019-10-31 21:00:12 +03:00
|
|
|
const MIME_TYPE = 'text/plain';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2024-08-08 04:43:26 +03:00
|
|
|
protected array $feed = [];
|
2023-09-25 22:18:48 +03:00
|
|
|
protected array $items = [];
|
2024-08-08 04:43:26 +03:00
|
|
|
protected string $charset = 'UTF-8';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2024-08-08 04:43:26 +03:00
|
|
|
protected int $lastModified;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2024-01-09 22:18:33 +03:00
|
|
|
abstract public function stringify();
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2024-01-09 22:18:33 +03:00
|
|
|
public function setFeed(array $feed)
|
2016-09-10 21:41:11 +03:00
|
|
|
{
|
2024-01-09 22:18:33 +03:00
|
|
|
$default = [
|
|
|
|
'name' => '',
|
|
|
|
'uri' => '',
|
|
|
|
'icon' => '',
|
|
|
|
'donationUri' => '',
|
|
|
|
];
|
|
|
|
$this->feed = array_merge($default, $feed);
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2024-01-09 22:18:33 +03:00
|
|
|
public function getFeed(): array
|
2018-08-25 22:00:38 +03:00
|
|
|
{
|
2024-01-09 22:18:33 +03:00
|
|
|
return $this->feed;
|
2018-08-25 22:00:38 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2023-10-13 12:24:22 +03:00
|
|
|
public function setItems(array $items): void
|
2016-09-10 21:41:11 +03:00
|
|
|
{
|
2024-08-08 04:43:26 +03:00
|
|
|
foreach ($items as $item) {
|
|
|
|
$this->items[] = FeedItem::fromArray($item);
|
|
|
|
}
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2023-09-25 22:18:48 +03:00
|
|
|
/**
|
|
|
|
* @return FeedItem[] The items
|
|
|
|
*/
|
|
|
|
public function getItems(): array
|
2016-09-10 21:41:11 +03:00
|
|
|
{
|
|
|
|
return $this->items;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2024-01-09 22:18:33 +03:00
|
|
|
public function getMimeType(): string
|
2016-09-10 21:41:11 +03:00
|
|
|
{
|
2024-01-09 22:18:33 +03:00
|
|
|
return static::MIME_TYPE;
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2024-01-09 22:18:33 +03:00
|
|
|
public function setCharset(string $charset)
|
2016-09-10 21:41:11 +03:00
|
|
|
{
|
2024-01-09 22:18:33 +03:00
|
|
|
$this->charset = $charset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCharset(): string
|
|
|
|
{
|
|
|
|
return $this->charset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLastModified(int $lastModified)
|
|
|
|
{
|
|
|
|
$this->lastModified = $lastModified;
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
2016-09-05 19:05:19 +03:00
|
|
|
}
|