CotisationCreator.php 1021 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Service\Cotisation;
  4. use App\ApiResources\Cotisation\Cotisation;
  5. use App\Repository\Organization\OrganizationRepository;
  6. /**
  7. * Class CotisationCreator : Service contenant les manipulations associés à la ressource Cotisation
  8. * @package App\Service\Cotisation
  9. */
  10. class CotisationCreator
  11. {
  12. public function __construct(
  13. private OrganizationRepository $organizationRepository,
  14. private Utils $cotisationUtils
  15. )
  16. { }
  17. public function getCotisation(int $organizationId): Cotisation{
  18. $cotisation = new Cotisation();
  19. $cotisation->setOrganizationId($organizationId);
  20. $cotisation->setCotisationYear($this->cotisationUtils->getCurrentCotisationYear());
  21. $organization = $this->organizationRepository->find($organizationId);
  22. $cotisation->setAlertState($this->cotisationUtils->getAlertState(
  23. $organization,
  24. $cotisation->getCotisationYear())
  25. );
  26. return $cotisation;
  27. }
  28. }