33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\WorkingDays;
|
|
|
|
use App\Services\WorkingDays\Date\MonToFriWorkingDayDeterminer;
|
|
use App\Services\WorkingDays\PublicHolidays\PublicHolidaysStateFactory;
|
|
use App\Services\WorkingDays\Utils\MultipleWorkingDayDeterminer;
|
|
|
|
class WorkingDayDeterminerFactory
|
|
{
|
|
public function __construct(
|
|
private readonly PublicHolidaysStateFactory $publicHolidaysStateFactory,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Create a working day determiner for the given country.
|
|
* @param string $countryCode
|
|
* @return WorkingDayDeterminerInterface
|
|
*/
|
|
public function createForCountry(string $countryCode): WorkingDayDeterminerInterface
|
|
{
|
|
return match ($countryCode) {
|
|
'CZ' => new MultipleWorkingDayDeterminer(
|
|
[ new MonToFriWorkingDayDeterminer(), $this->publicHolidaysStateFactory->createDeterminerForCountry($countryCode) ],
|
|
),
|
|
default => throw new \InvalidArgumentException('Unsupported country code'),
|
|
};
|
|
}
|
|
}
|