2023-08-24 12:48:10 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace OCA\RePod\Core\EpisodeAction;
|
|
|
|
|
|
|
|
use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction;
|
|
|
|
|
|
|
|
/**
|
2024-01-11 00:14:15 +01:00
|
|
|
* Base: https://github.com/pbek/nextcloud-nextpod/blob/main/lib/Core/EpisodeAction/EpisodeActionExtraData.php.
|
|
|
|
* Specs: https://github.com/Podcast-Standards-Project/PSP-1-Podcast-RSS-Specification/blob/main/README.md#required-item-elements.
|
2023-08-24 12:48:10 +02:00
|
|
|
*
|
|
|
|
* @psalm-import-type EpisodeActionType from EpisodeAction
|
|
|
|
*
|
|
|
|
* @psalm-type EpisodeActionExtraDataType = array{
|
2024-01-14 00:40:52 +01:00
|
|
|
* title: string,
|
2024-01-11 00:14:15 +01:00
|
|
|
* url: ?string,
|
|
|
|
* name: string,
|
|
|
|
* link: ?string,
|
|
|
|
* image: ?string,
|
|
|
|
* description: ?string,
|
2023-08-24 12:48:10 +02:00
|
|
|
* fetchedAtUnix: int,
|
2024-01-11 00:14:15 +01:00
|
|
|
* guid: string,
|
|
|
|
* type: ?string,
|
|
|
|
* size: ?int,
|
|
|
|
* pubDate: ?\DateTime,
|
|
|
|
* duration: ?int,
|
|
|
|
* action: ?EpisodeActionType
|
2023-08-24 12:48:10 +02:00
|
|
|
* }
|
|
|
|
*/
|
|
|
|
class EpisodeActionExtraData implements \JsonSerializable
|
|
|
|
{
|
|
|
|
public function __construct(
|
2024-01-14 00:40:52 +01:00
|
|
|
private string $title,
|
2024-01-11 00:14:15 +01:00
|
|
|
private ?string $url,
|
|
|
|
private string $name,
|
|
|
|
private ?string $link,
|
|
|
|
private ?string $image,
|
|
|
|
private ?string $description,
|
2023-08-24 12:48:10 +02:00
|
|
|
private int $fetchedAtUnix,
|
2024-01-11 00:14:15 +01:00
|
|
|
private string $guid,
|
|
|
|
private ?string $type,
|
|
|
|
private ?int $size,
|
|
|
|
private ?\DateTime $pubDate,
|
|
|
|
private ?int $duration,
|
|
|
|
private ?EpisodeAction $action
|
|
|
|
) {}
|
2023-08-24 12:48:10 +02:00
|
|
|
|
2023-12-23 17:25:20 +01:00
|
|
|
public function __toString(): string {
|
2024-01-11 00:14:15 +01:00
|
|
|
return $this->url ?? '/no episodeUrl/';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUrl(): ?string {
|
|
|
|
return $this->url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): string {
|
|
|
|
return $this->name;
|
2023-08-24 12:48:10 +02:00
|
|
|
}
|
|
|
|
|
2024-01-11 00:14:15 +01:00
|
|
|
public function getLink(): ?string {
|
|
|
|
return $this->link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getImage(): ?string {
|
|
|
|
return $this->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription(): ?string {
|
|
|
|
return $this->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFetchedAtUnix(): int {
|
|
|
|
return $this->fetchedAtUnix;
|
2023-08-28 17:44:17 +02:00
|
|
|
}
|
|
|
|
|
2024-01-11 00:14:15 +01:00
|
|
|
public function getGuid(): string {
|
|
|
|
return $this->guid;
|
2023-08-24 19:03:11 +02:00
|
|
|
}
|
|
|
|
|
2024-01-11 00:14:15 +01:00
|
|
|
public function getType(): ?string {
|
|
|
|
return $this->type;
|
2023-08-24 19:03:11 +02:00
|
|
|
}
|
|
|
|
|
2024-01-11 00:14:15 +01:00
|
|
|
public function getSize(): ?int {
|
|
|
|
return $this->size;
|
2023-08-24 19:03:11 +02:00
|
|
|
}
|
|
|
|
|
2024-01-11 00:14:15 +01:00
|
|
|
public function getPubDate(): ?\DateTime {
|
|
|
|
return $this->pubDate;
|
2023-08-29 12:04:14 +02:00
|
|
|
}
|
|
|
|
|
2024-01-11 00:14:15 +01:00
|
|
|
public function getDuration(): ?int {
|
|
|
|
return $this->duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAction(): ?EpisodeAction {
|
|
|
|
return $this->action;
|
2023-08-24 12:48:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return EpisodeActionExtraDataType
|
|
|
|
*/
|
2023-12-23 17:25:20 +01:00
|
|
|
public function toArray(): array {
|
2023-08-24 12:48:10 +02:00
|
|
|
return
|
|
|
|
[
|
2024-01-14 00:40:52 +01:00
|
|
|
'title' => $this->title,
|
2024-01-11 00:14:15 +01:00
|
|
|
'url' => $this->url,
|
|
|
|
'name' => $this->name,
|
|
|
|
'link' => $this->link,
|
|
|
|
'image' => $this->image,
|
|
|
|
'description' => $this->description,
|
2023-08-24 12:48:10 +02:00
|
|
|
'fetchedAtUnix' => $this->fetchedAtUnix,
|
2024-01-11 00:14:15 +01:00
|
|
|
'guid' => $this->guid,
|
|
|
|
'type' => $this->type,
|
|
|
|
'size' => $this->size,
|
|
|
|
'pubDate' => $this->pubDate,
|
|
|
|
'duration' => $this->duration,
|
|
|
|
'action' => $this->action ? $this->action->toArray() : null,
|
2023-08-24 12:48:10 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return EpisodeActionExtraDataType
|
|
|
|
*/
|
2023-12-23 17:25:20 +01:00
|
|
|
public function jsonSerialize(): mixed {
|
2023-08-24 12:48:10 +02:00
|
|
|
return $this->toArray();
|
|
|
|
}
|
|
|
|
}
|