<?php

namespace DMD\LaLigaApi\Service\Season;

use DMD\LaLigaApi\Dto\SeasonDto;
use DMD\LaLigaApi\Entity\Season;
use DMD\LaLigaApi\Entity\Team;

class SeasonFactory
{
    public static function create(SeasonDto $seasonDto): Season
    {
        $seasonEntity = new Season();
        $seasonEntity->setActive(true);
        if (!empty($seasonDto->dateStart))
        {
            $seasonEntity->setDateStart($seasonDto->dateStart);
        }
        if (isset($seasonDto->pointsPerWin))
        {
            $seasonEntity->setPointsPerWin($seasonDto->pointsPerWin);
        }
        if (isset($seasonDto->pointsPerDraw))
        {
            $seasonEntity->setPointsPerDraw($seasonDto->pointsPerDraw);
        }
        if (isset($seasonDto->pointsPerLoss))
        {
            $seasonEntity->setPointsPerLoss($seasonDto->pointsPerLoss);
        }
        return $seasonEntity;
    }
}