Add the transaction entity and the episodes directory
This commit is contained in:
parent
d00d55371c
commit
af1341fd4a
@ -50,6 +50,7 @@ final class CreateEpisodesTable extends AbstractMigration
|
||||
->addColumn('length', 'integer', [ 'signed' => false ])
|
||||
->addColumn('description', 'text')
|
||||
->addColumn('explicit', 'boolean', [ 'default' => false ])
|
||||
->addColumn('serial_number', 'integer', [ 'signed' => false ])
|
||||
->addColumn('channel_id', 'integer', [
|
||||
'signed' => false,
|
||||
'null' => false
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Slovocast\Domain\Entity;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Slovocast\Domain\Entity as EntityTrait;
|
||||
|
||||
class Episode
|
||||
@ -15,15 +16,48 @@ class Episode
|
||||
private string $link,
|
||||
private int $length,
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
protected function parseDuration(int $length): string
|
||||
public static function parseDuration(int $length): string
|
||||
{
|
||||
$hours = floor($length / 3600);
|
||||
$minutes = floor($length / 60) % 60;
|
||||
|
31
app/src/Domain/Entity/Transaction.php
Normal file
31
app/src/Domain/Entity/Transaction.php
Normal 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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user