Add the transaction entity and the episodes directory

This commit is contained in:
Dave Smith-Hayes 2024-11-11 20:51:00 -05:00
parent d00d55371c
commit af1341fd4a
4 changed files with 89 additions and 2 deletions

View File

@ -50,6 +50,7 @@ final class CreateEpisodesTable extends AbstractMigration
->addColumn('length', 'integer', [ 'signed' => false ]) ->addColumn('length', 'integer', [ 'signed' => false ])
->addColumn('description', 'text') ->addColumn('description', 'text')
->addColumn('explicit', 'boolean', [ 'default' => false ]) ->addColumn('explicit', 'boolean', [ 'default' => false ])
->addColumn('serial_number', 'integer', [ 'signed' => false ])
->addColumn('channel_id', 'integer', [ ->addColumn('channel_id', 'integer', [
'signed' => false, 'signed' => false,
'null' => false 'null' => false

View File

@ -2,6 +2,7 @@
namespace Slovocast\Domain\Entity; namespace Slovocast\Domain\Entity;
use DateTimeImmutable;
use Slovocast\Domain\Entity as EntityTrait; use Slovocast\Domain\Entity as EntityTrait;
class Episode class Episode
@ -15,15 +16,48 @@ class Episode
private string $link, private string $link,
private int $length, private int $length,
private string $description, private string $description,
private bool $explicit = false, private int $serialNumber,
private bool $explicit,
private DateTimeImmutable $publishedDate,
private string $episodeType,
) { ) {
$this->duration = $this->parseDuration($this->length); $this->duration = $this->parseDuration($this->length);
} }
public function getTitle(): string
{
return $this->title;
}
public function getLink(): string
{
return $this->link;
}
public function getLength(): int
{
return $this->length;
}
public function getDuration(): string
{
return $this->duration;
}
public function getSerialNumber(): int
{
return $this->serialNumber;
}
public function isExplicit(): bool
{
return $this->explicit;
}
/** /**
* @TODO Figure out how to parse second to HH:MM:SS * @TODO Figure out how to parse second to HH:MM:SS
*/ */
protected function parseDuration(int $length): string public static function parseDuration(int $length): string
{ {
$hours = floor($length / 3600); $hours = floor($length / 3600);
$minutes = floor($length / 60) % 60; $minutes = floor($length / 60) % 60;

View File

@ -0,0 +1,31 @@
<?php
namespace Slovocast\Domain\Entity;
use Slovocast\Domain\Entity as EntityTrait;
class Transaction
{
use EntityTrait;
public function __construct(
private string $code,
private string $type,
private int $total,
) { }
public function getCode(): string
{
return $this->code;
}
public function getType(): string
{
return $this->type;
}
public function getTotal(): int
{
return $this->total;
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Slovocast\Domain\Repository\Episode;
use Slovocast\Domain\Entity\Episode;
use Slovocast\Domain\Entity\Channel;
use Slovocast\Domain\RepositoryInterface;
interface EpisodeRepositoryInterface extends RepositoryInterface
{
public function get(int $id): Episode;
/**
* @param Channel $channel
* @return Episode[]
*/
public function getFromChannel(Channel $channel): array;
public function create(Episode $episode): Episode;
public function update(Episode $episode): bool;
public function delete(Episode $episode): bool;
}