52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Slovocast\Domain\Repository\Episode;
|
|
|
|
use Slovocast\Domain\Entity\Episode;
|
|
use Slovocast\Domain\Entity\Episode\File;
|
|
use Slovocast\Exception\EntityNotFoundException;
|
|
use Slovocast\Infrastructure\Api\Database\DatabaseHandlerInterface;
|
|
|
|
class EpisodeFileRepository implements EpisodeFileRepositoryInterface
|
|
{
|
|
public function __construct(
|
|
private DatabaseHandlerInterface $db,
|
|
) { }
|
|
|
|
public function get(int $id): File
|
|
{
|
|
$query = "SELECT * FROM files WHERE id = :id";
|
|
$results = $this->db->query($query, [ ':id' => $id ]);
|
|
|
|
if (!is_array($results) || empty($results)) {
|
|
throw new EntityNotFoundException("Unable to file File Metadata");
|
|
}
|
|
|
|
$row = array_shift($results);
|
|
return File::fromArray($row);
|
|
}
|
|
|
|
public function getFromEpisode(Episode $episode): File
|
|
{
|
|
|
|
}
|
|
|
|
public function create(File $file): File
|
|
{
|
|
|
|
}
|
|
|
|
public function update(File $file): bool
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* @TODO Determine how to soft and fully delete the File data.
|
|
*/
|
|
public function delete(File $file): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|