135 lines
3.4 KiB
PHP
135 lines
3.4 KiB
PHP
<?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,
|
|
* episodeGuid: string,
|
|
* episodePubDate: ?\DateTime,
|
|
* episodeFilesize: ?int,
|
|
* episodeDuration: ?int,
|
|
* 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,
|
|
private string $episodeGuid,
|
|
private ?\DateTime $episodePubDate,
|
|
private ?int $episodeFilesize,
|
|
private ?int $episodeDuration,
|
|
private ?EpisodeAction $episodeAction
|
|
) {
|
|
$this->episodeUrl = $episodeUrl;
|
|
$this->podcastName = $podcastName;
|
|
$this->episodeName = $episodeName;
|
|
$this->episodeLink = $episodeLink;
|
|
$this->episodeImage = $episodeImage;
|
|
$this->episodeDescription = $episodeDescription;
|
|
$this->fetchedAtUnix = $fetchedAtUnix;
|
|
$this->episodeGuid = $episodeGuid;
|
|
$this->episodePubDate = $episodePubDate;
|
|
$this->episodeFilesize = $episodeFilesize;
|
|
$this->episodeDuration = $episodeDuration;
|
|
$this->episodeAction = $episodeAction;
|
|
}
|
|
|
|
public function __toString(): string {
|
|
return $this->episodeUrl ?? '/no episodeUrl/';
|
|
}
|
|
|
|
public function getEpisodeGuid(): string {
|
|
return $this->episodeGuid;
|
|
}
|
|
|
|
public function getEpisodePubDate(): ?\DateTime {
|
|
return $this->episodePubDate;
|
|
}
|
|
|
|
public function getEpisodeFilesize(): ?int {
|
|
return $this->episodeFilesize;
|
|
}
|
|
|
|
public function getEpisodeDuration(): ?int {
|
|
return $this->episodeDuration;
|
|
}
|
|
|
|
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,
|
|
'episodeGuid' => $this->episodeGuid,
|
|
'episodePubDate' => $this->episodePubDate,
|
|
'episodeFilesize' => $this->episodeFilesize,
|
|
'episodeDuration' => $this->episodeDuration,
|
|
'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;
|
|
}
|
|
}
|