2023-08-24 10:48:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace OCA\RePod\Core\EpisodeAction;
|
|
|
|
|
|
|
|
use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* https://github.com/pbek/nextcloud-nextpod/blob/main/lib/Core/EpisodeAction/EpisodeActionExtraData.php.
|
|
|
|
*
|
|
|
|
* @psalm-import-type EpisodeActionType from EpisodeAction
|
|
|
|
*
|
|
|
|
* @psalm-type EpisodeActionExtraDataType = array{
|
|
|
|
* episodeUrl: ?string,
|
|
|
|
* podcastName: ?string,
|
|
|
|
* episodeName: ?string,
|
|
|
|
* episodeLink: ?string,
|
|
|
|
* episodeImage: ?string,
|
|
|
|
* episodeDescription: ?string,
|
|
|
|
* fetchedAtUnix: int,
|
2023-08-24 17:03:11 +00:00
|
|
|
* pubDate: ?\DateTime,
|
|
|
|
* filesize: ?int,
|
|
|
|
* duration: ?int,
|
2023-08-24 10:48:10 +00:00
|
|
|
* episodeAction: ?EpisodeActionType
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
class EpisodeActionExtraData implements \JsonSerializable
|
|
|
|
{
|
|
|
|
public function __construct(
|
|
|
|
private ?string $episodeUrl,
|
|
|
|
private ?string $podcastName,
|
|
|
|
private ?string $episodeName,
|
|
|
|
private ?string $episodeLink,
|
|
|
|
private ?string $episodeImage,
|
|
|
|
private ?string $episodeDescription,
|
|
|
|
private int $fetchedAtUnix,
|
2023-08-24 17:03:11 +00:00
|
|
|
private ?\DateTime $pubDate,
|
|
|
|
private ?int $filesize,
|
|
|
|
private ?int $duration,
|
2023-08-24 10:48:10 +00:00
|
|
|
private ?EpisodeAction $episodeAction
|
|
|
|
) {
|
|
|
|
$this->episodeUrl = $episodeUrl;
|
|
|
|
$this->podcastName = $podcastName;
|
|
|
|
$this->episodeName = $episodeName;
|
|
|
|
$this->episodeLink = $episodeLink;
|
|
|
|
$this->episodeImage = $episodeImage;
|
|
|
|
$this->episodeDescription = $episodeDescription;
|
|
|
|
$this->fetchedAtUnix = $fetchedAtUnix;
|
2023-08-24 17:03:11 +00:00
|
|
|
$this->pubDate = $pubDate;
|
|
|
|
$this->filesize = $filesize;
|
|
|
|
$this->duration = $duration;
|
2023-08-24 10:48:10 +00:00
|
|
|
$this->episodeAction = $episodeAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString(): string
|
|
|
|
{
|
|
|
|
return $this->episodeUrl ?? '/no episodeUrl/';
|
|
|
|
}
|
|
|
|
|
2023-08-24 17:03:11 +00:00
|
|
|
public function getPubDate(): ?\DateTime
|
|
|
|
{
|
|
|
|
return $this->pubDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFilesize(): ?int
|
|
|
|
{
|
|
|
|
return $this->filesize;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDuration(): ?int
|
|
|
|
{
|
|
|
|
return $this->duration;
|
|
|
|
}
|
|
|
|
|
2023-08-24 10:48:10 +00:00
|
|
|
public function getEpisodeAction(): ?EpisodeAction
|
|
|
|
{
|
|
|
|
return $this->episodeAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEpisodeUrl(): ?string
|
|
|
|
{
|
|
|
|
return $this->episodeUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return EpisodeActionExtraDataType
|
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return
|
|
|
|
[
|
|
|
|
'podcastName' => $this->podcastName,
|
|
|
|
'episodeUrl' => $this->episodeUrl,
|
|
|
|
'episodeName' => $this->episodeName,
|
|
|
|
'episodeLink' => $this->episodeLink,
|
|
|
|
'episodeImage' => $this->episodeImage,
|
|
|
|
'episodeDescription' => $this->episodeDescription,
|
|
|
|
'fetchedAtUnix' => $this->fetchedAtUnix,
|
2023-08-24 17:03:11 +00:00
|
|
|
'pubDate' => $this->pubDate,
|
|
|
|
'filesize' => $this->filesize,
|
|
|
|
'duration' => $this->duration,
|
2023-08-24 10:48:10 +00:00
|
|
|
'episodeAction' => $this->episodeAction ? $this->episodeAction->toArray() : null,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return EpisodeActionExtraDataType
|
|
|
|
*/
|
|
|
|
public function jsonSerialize(): mixed
|
|
|
|
{
|
|
|
|
return $this->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPodcastName(): ?string
|
|
|
|
{
|
|
|
|
return $this->podcastName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEpisodeName(): ?string
|
|
|
|
{
|
|
|
|
return $this->episodeName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEpisodeLink(): ?string
|
|
|
|
{
|
|
|
|
return $this->episodeLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFetchedAtUnix(): int
|
|
|
|
{
|
|
|
|
return $this->fetchedAtUnix;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEpisodeImage(): ?string
|
|
|
|
{
|
|
|
|
return $this->episodeImage;
|
|
|
|
}
|
|
|
|
}
|