Add a file factory
This commit is contained in:
parent
e59b1ea2d1
commit
551d5043c1
37
app/src/Domain/Factory/FileFactory.php
Normal file
37
app/src/Domain/Factory/FileFactory.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Domain\Factory;
|
||||
|
||||
use Slovocast\Domain\Entity\Episode\File;
|
||||
use Slovocast\Domain\FactoryInterface;
|
||||
|
||||
class FileFactory implements FactoryInterface
|
||||
{
|
||||
public static function fromArray(array $props): File
|
||||
{
|
||||
$file = new File(
|
||||
$props['url'],
|
||||
(int) $props['length'],
|
||||
$props['type']
|
||||
);
|
||||
|
||||
if ($props['id']) {
|
||||
$file->setId($props['id']);
|
||||
}
|
||||
|
||||
if ($props['createAt']) {
|
||||
$file->setCreatedAt($props['createdAt']);
|
||||
}
|
||||
|
||||
if ($props['updatedAt']) {
|
||||
$file->setUpdatedAt($props['updatedAt']);
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
public static function toArray(File $file): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user