2023-08-24 12:48:10 +02: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-28 17:44:17 +02:00
|
|
|
* episodeGuid: string,
|
2023-08-24 20:53:54 +02:00
|
|
|
* episodePubDate: ?\DateTime,
|
|
|
|
* episodeFilesize: ?int,
|
2023-08-29 08:48:54 +02:00
|
|
|
* episodeDuration: ?int
|
2023-08-24 12:48:10 +02:00
|
|
|
* }
|
|
|
|
*/
|
|
|
|
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-28 17:44:17 +02:00
|
|
|
private string $episodeGuid,
|
2023-08-24 20:53:54 +02:00
|
|
|
private ?\DateTime $episodePubDate,
|
|
|
|
private ?int $episodeFilesize,
|
2023-08-29 08:48:54 +02:00
|
|
|
private ?int $episodeDuration
|
2023-08-24 12:48:10 +02:00
|
|
|
) {
|
|
|
|
$this->episodeUrl = $episodeUrl;
|
|
|
|
$this->podcastName = $podcastName;
|
|
|
|
$this->episodeName = $episodeName;
|
|
|
|
$this->episodeLink = $episodeLink;
|
|
|
|
$this->episodeImage = $episodeImage;
|
|
|
|
$this->episodeDescription = $episodeDescription;
|
|
|
|
$this->fetchedAtUnix = $fetchedAtUnix;
|
2023-08-28 17:44:17 +02:00
|
|
|
$this->episodeGuid = $episodeGuid;
|
2023-08-24 20:53:54 +02:00
|
|
|
$this->episodePubDate = $episodePubDate;
|
|
|
|
$this->episodeFilesize = $episodeFilesize;
|
|
|
|
$this->episodeDuration = $episodeDuration;
|
2023-08-24 12:48:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString(): string
|
|
|
|
{
|
|
|
|
return $this->episodeUrl ?? '/no episodeUrl/';
|
|
|
|
}
|
|
|
|
|
2023-08-28 17:44:17 +02:00
|
|
|
public function getEpisodeGuid(): string
|
|
|
|
{
|
|
|
|
return $this->episodeGuid;
|
|
|
|
}
|
|
|
|
|
2023-08-24 20:53:54 +02:00
|
|
|
public function getEpisodePubDate(): ?\DateTime
|
2023-08-24 19:03:11 +02:00
|
|
|
{
|
2023-08-24 20:53:54 +02:00
|
|
|
return $this->episodePubDate;
|
2023-08-24 19:03:11 +02:00
|
|
|
}
|
|
|
|
|
2023-08-24 20:53:54 +02:00
|
|
|
public function getEpisodeFilesize(): ?int
|
2023-08-24 19:03:11 +02:00
|
|
|
{
|
2023-08-24 20:53:54 +02:00
|
|
|
return $this->episodeFilesize;
|
2023-08-24 19:03:11 +02:00
|
|
|
}
|
|
|
|
|
2023-08-24 20:53:54 +02:00
|
|
|
public function getEpisodeDuration(): ?int
|
2023-08-24 19:03:11 +02:00
|
|
|
{
|
2023-08-24 20:53:54 +02:00
|
|
|
return $this->episodeDuration;
|
2023-08-24 19:03:11 +02:00
|
|
|
}
|
|
|
|
|
2023-08-24 12:48:10 +02:00
|
|
|
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-28 17:44:17 +02:00
|
|
|
'episodeGuid' => $this->episodeGuid,
|
2023-08-24 20:53:54 +02:00
|
|
|
'episodePubDate' => $this->episodePubDate,
|
|
|
|
'episodeFilesize' => $this->episodeFilesize,
|
|
|
|
'episodeDuration' => $this->episodeDuration,
|
2023-08-24 12:48:10 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
}
|
|
|
|
}
|