castopod/app/Entities/Actor.php
Yassine Doghri 231d578d64
refactor: add phpstan and update code to adhere to level 5
- move and refactor Image.php from Libraries to Entities folder
- update some database field names
/ types
- update composer packages
2021-05-12 14:00:25 +00:00

53 lines
1.0 KiB
PHP

<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use ActivityPub\Entities\Actor as ActivityPubActor;
use App\Models\PodcastModel;
use RuntimeException;
/**
* @property Podcast|null $podcast
* @property boolean $is_podcast
*/
class Actor extends ActivityPubActor
{
/**
* @var Podcast|null
*/
protected $podcast;
/**
* @var boolean
*/
protected $is_podcast;
public function getIsPodcast(): bool
{
return $this->podcast !== null;
}
public function getPodcast(): ?Podcast
{
if ($this->id === null) {
throw new RuntimeException(
'Podcast id must be set before getting associated podcast.',
);
}
if ($this->podcast === null) {
$this->podcast = (new PodcastModel())->getPodcastByActorId(
$this->id,
);
}
return $this->podcast;
}
}