Newer
Older
<?php

Yassine Doghri
committed
declare(strict_types=1);
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use App\Models\PodcastModel;

Yassine Doghri
committed
use Modules\Fediverse\Entities\Actor as FediverseActor;

Yassine Doghri
committed
use RuntimeException;
/**
* @property Podcast|null $podcast
* @property boolean $is_podcast
*/

Yassine Doghri
committed
class Actor extends FediverseActor
{

Yassine Doghri
committed
protected ?Podcast $podcast = null;

Yassine Doghri
committed
protected bool $is_podcast = false;
public function getIsPodcast(): bool
{
return $this->getPodcast() instanceof Podcast;
}
public function getPodcast(): ?Podcast
{
if ($this->id === null) {

Yassine Doghri
committed
throw new RuntimeException('Podcast id must be set before getting associated podcast.');
}
if (! $this->podcast instanceof Podcast) {

Yassine Doghri
committed
$this->podcast = (new PodcastModel())->getPodcastByActorId($this->id);
}
return $this->podcast;
}

Yassine Doghri
committed

Yassine Doghri
committed
public function getAvatarImageUrl(): string
{
if ($this->podcast instanceof Podcast) {

Yassine Doghri
committed
return $this->podcast->cover->thumbnail_url;
}

Yassine Doghri
committed
return parent::getAvatarImageUrl();

Yassine Doghri
committed
}

Yassine Doghri
committed
public function getAvatarImageMimetype(): string
{
if ($this->podcast instanceof Podcast) {

Yassine Doghri
committed
return $this->podcast->cover->thumbnail_mimetype;
}

Yassine Doghri
committed
return parent::getAvatarImageMimetype();

Yassine Doghri
committed
}