<?php

namespace DMD\LaLigaApi\Service\Common;

use DMD\LaLigaApi\Dto\FacilityDto;
use DMD\LaLigaApi\Entity\Facility;

class FacilityFactory
{
    public static function create(FacilityDto $facilityDto): Facility
    {
        $facilityEntity = new Facility();
        if (!empty($facilityDto->name))
        {
            $facilityEntity->setName($facilityDto->name);
        }
        if (!empty($facilityDto->address))
        {
            $facilityEntity->setAddress($facilityDto->address);
        }
        if (!empty($facilityDto->availableHourList))
        {
            $facilityEntity->setAvailableHours($facilityDto->availableHourList);
        }
        $facilityEntity->setActive(true);
        return $facilityEntity;
    }
}