Files
LaLiga-BackEnd/src/Dto/FileDto.php
T
Daniel Guzman efe08af5cc
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
Get leagues, teams. Create teams.
2024-07-21 00:12:19 +02:00

71 lines
1.8 KiB
PHP

<?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->fillFromEntity($fileEntity->getSeason());
$this->seasonDto = $seasonDto;
}
if ($fileEntity->getGame() !== null)
{
$gameDto = new GameDto();
$gameDto->fillFromObject($fileEntity->getGame());
$this->gameDto = $gameDto;
}
}
public function validate(): void
{
}
}