repod/lib/Core/EpisodeAction/EpisodeActionExtraData.php
Michel Roux 11026af80e
All checks were successful
repod / nextcloud (push) Successful in 56s
repod / nodejs (push) Successful in 1m27s
Add missing informations
2023-08-24 19:03:11 +02:00

140 lines
3.0 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,
* pubDate: ?\DateTime,
* filesize: ?int,
* duration: ?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 ?\DateTime $pubDate,
private ?int $filesize,
private ?int $duration,
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->pubDate = $pubDate;
$this->filesize = $filesize;
$this->duration = $duration;
$this->episodeAction = $episodeAction;
}
public function __toString(): string
{
return $this->episodeUrl ?? '/no episodeUrl/';
}
public function getPubDate(): ?\DateTime
{
return $this->pubDate;
}
public function getFilesize(): ?int
{
return $this->filesize;
}
public function getDuration(): ?int
{
return $this->duration;
}
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,
'pubDate' => $this->pubDate,
'filesize' => $this->filesize,
'duration' => $this->duration,
'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;
}
}