welcome back to dyb-tech
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Dto;
|
||||
|
||||
use DMD\LaLigaApi\Entity\File;
|
||||
|
||||
class FileDto
|
||||
{
|
||||
public int $id;
|
||||
public string $name;
|
||||
public string $type;
|
||||
public \DateTime $createdAt;
|
||||
public GameDto $gameDto;
|
||||
public PlayerDto $playerDto;
|
||||
public SeasonDto $seasonDto;
|
||||
|
||||
public function fillFromArray(array $dataList): void
|
||||
{
|
||||
if (isset($dataList['id']))
|
||||
{
|
||||
$this->id = $dataList['id'];
|
||||
}
|
||||
if (!empty($dataList['name']))
|
||||
{
|
||||
$this->name = $dataList['name'];
|
||||
}
|
||||
if (!empty($dataList['type']))
|
||||
{
|
||||
$this->type = $dataList['type'];
|
||||
}
|
||||
if (!empty($dataList['createdAt']))
|
||||
{
|
||||
$this->createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $dataList['createdAt']);
|
||||
}
|
||||
}
|
||||
|
||||
public function fillFromObject(File $fileEntity): void
|
||||
{
|
||||
if ($fileEntity->getId() !== null)
|
||||
{
|
||||
$this->id = $fileEntity->getId();
|
||||
}
|
||||
if ($fileEntity->getName() !== null)
|
||||
{
|
||||
$this->name = $fileEntity->getName();
|
||||
}
|
||||
if ($fileEntity->getPlayer() !== null)
|
||||
{
|
||||
$playerDto = new PlayerDto();
|
||||
$playerDto->fillFromObject($fileEntity->getPlayer());
|
||||
$this->playerDto = $playerDto;
|
||||
}
|
||||
if ($fileEntity->getSeason() !== null)
|
||||
{
|
||||
$seasonDto = new SeasonDto();
|
||||
$seasonDto->fillFromObject($fileEntity->getSeason());
|
||||
$this->seasonDto = $seasonDto;
|
||||
}
|
||||
if ($fileEntity->getGame() !== null)
|
||||
{
|
||||
$gameDto = new GameDto();
|
||||
$gameDto->fillFromObject($fileEntity->getGame());
|
||||
$this->gameDto = $gameDto;
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user