<?php

declare(strict_types=1);

namespace App\Service\Organization;

use App\Service\Utils\DatesUtils;

/**
 * Class OrganizationProfileCreator : Service contenant les manipulations associés à la ressource OrganizationProfile.
 */
class Trial
{
    public function __construct(
        private DatesUtils $datesUtils,
    ) {
    }

    /**
     * Retourne le décompte sur 30 jours du dernier lancement d'essai.
     *
     * @return int
     */
    public function getTrialCountdown(?\DateTimeInterface $trialStartDate)
    {
        if (empty($trialStartDate)) {
            return 0;
        }

        $daysSince = $this->datesUtils::daysSince($trialStartDate);
        if ($daysSince > 30) {
            return 0;
        }

        return 30 - $daysSince;
    }
}
