113 lines
2.5 KiB
PHP
113 lines
2.5 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,
|
||
|
* 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 ?EpisodeAction $episodeAction
|
||
|
) {
|
||
|
$this->episodeUrl = $episodeUrl;
|
||
|
$this->podcastName = $podcastName;
|
||
|
$this->episodeName = $episodeName;
|
||
|
$this->episodeLink = $episodeLink;
|
||
|
$this->episodeImage = $episodeImage;
|
||
|
$this->episodeDescription = $episodeDescription;
|
||
|
$this->fetchedAtUnix = $fetchedAtUnix;
|
||
|
$this->episodeAction = $episodeAction;
|
||
|
}
|
||
|
|
||
|
public function __toString(): string
|
||
|
{
|
||
|
return $this->episodeUrl ?? '/no episodeUrl/';
|
||
|
}
|
||
|
|
||
|
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,
|
||
|
'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;
|
||
|
}
|
||
|
}
|