feat(providers): add provider for working days
This commit is contained in:
parent
b0e99f5238
commit
1a66420eb1
57
app/Providers/WorkingDaysProvider.php
Normal file
57
app/Providers/WorkingDaysProvider.php
Normal 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
|
||||
{
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\WorkingDaysProvider::class,
|
||||
App\Providers\Swagger::class,
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user