feat(services): add public holidays states infra

This commit is contained in:
2024-08-07 12:58:58 +02:00
parent da77779525
commit 78bb9e6f09
5 changed files with 160 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace App\Services\WorkingDays\PublicHolidays;
use App\Services\WorkingDays\PublicHolidays\Storage\PublicHolidaysStorageInterface;
use App\Services\WorkingDays\WorkingDayDeterminerInterface;
class PublicHolidaysStateFactory
{
public function __construct(
private readonly PublicHolidaysStorageInterface $holidaysStorage,
) {
}
public function createStoreForCountry(string $countryCode): PublicHolidaysStateStorageInterface
{
return $this->getStateImpl($countryCode);
}
public function createDeterminerForCountry(string $countryCode): PublicHolidaysStateDeterminerInterface&WorkingDayDeterminerInterface
{
return $this->getStateImpl($countryCode);
}
/**
* @param string $countryCode
* @return PublicHolidaysStateDeterminer
*/
protected function getStateImpl(string $countryCode): PublicHolidaysStateDeterminer
{
return new PublicHolidaysStateDeterminer($this->holidaysStorage, $countryCode);
}
}