feat(providers): add provider for working days

This commit is contained in:
Ondrej Vlach 2024-08-07 13:01:11 +02:00
parent b0e99f5238
commit 1a66420eb1
No known key found for this signature in database
GPG Key ID: 7F141CDACEDEE2DE
2 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace App\Providers;
use App\Services\Utils\DurationConvertor;
use App\Services\WorkingDays\DurationSolverFactory;
use App\Services\WorkingDays\PublicHolidays\PublicHolidaysGeneratorFactory;
use App\Services\WorkingDays\PublicHolidays\PublicHolidaysStateFactory;
use App\Services\WorkingDays\PublicHolidays\Storage\DatabaseStorage;
use App\Services\WorkingDays\PublicHolidays\Storage\PublicHolidaysStorageInterface;
use App\Services\WorkingDays\WorkingDayDeterminerFactory;
use Illuminate\Support\ServiceProvider;
class WorkingDaysProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
$this->app->singleton(PublicHolidaysStorageInterface::class, function () {
return new DatabaseStorage();
});
$this->app->singleton(PublicHolidaysStateFactory::class, function() {
return new PublicHolidaysStateFactory(
$this->app->make(PublicHolidaysStorageInterface::class)
);
});
$this->app->singleton(WorkingDayDeterminerFactory::class, function() {
return new WorkingDayDeterminerFactory(
$this->app->make(PublicHolidaysStateFactory::class)
);
});
$this->app->singleton(DurationSolverFactory::class, function() {
return new DurationSolverFactory(
$this->app->make(WorkingDayDeterminerFactory::class),
$this->app->make(DurationConvertor::class)
);
});
$this->app->singleton(PublicHolidaysGeneratorFactory::class, function() {
return new PublicHolidaysGeneratorFactory();
});
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
}
}

View File

@ -1,5 +1,6 @@
<?php
return [
App\Providers\AppServiceProvider::class,
App\Providers\WorkingDaysProvider::class,
App\Providers\Swagger::class,
];