<?php
declare(strict_types=1);

namespace App\Service\Cotisation;

use App\ApiResources\Cotisation\Cotisation;
use App\Repository\Organization\OrganizationRepository;


/**
 * Class CotisationCreator : Service contenant les manipulations associés à la ressource Cotisation
 * @package App\Service\Cotisation
 */
class CotisationCreator
{
    public function __construct(
        private OrganizationRepository $organizationRepository,
        private Utils $cotisationUtils
    )
    { }

    public function getCotisation(int $organizationId): Cotisation{
        $cotisation = new Cotisation();
        $cotisation->setOrganizationId($organizationId);
        $cotisation->setCotisationYear($this->cotisationUtils->getCurrentCotisationYear());

        $organization = $this->organizationRepository->find($organizationId);
        $cotisation->setAlertState($this->cotisationUtils->getAlertState(
            $organization,
            $cotisation->getCotisationYear())
        );

        return $cotisation;
    }
}