CotisationCreator.php 1012 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. */
  9. class CotisationCreator
  10. {
  11. public function __construct(
  12. private readonly OrganizationRepository $organizationRepository,
  13. private readonly Utils $cotisationUtils,
  14. ) {
  15. }
  16. public function getCotisation(int $organizationId): Cotisation
  17. {
  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. }