toby/app/Domain/VacationTypeConfigRetriever.php
Adrian Hopek 3d9726039c
#43 - vacation summary for employee (#66)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* #5 - bump dependencies

* #43 - wip

* #43 - add composer script

* #43 - fix

* #43 - fix

* #43 - wip

* #43 - ecs fix

* #43 - cr fix

* #43 - cr fix

* #43 - fix

Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
2022-03-03 09:03:17 +01:00

46 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Toby\Domain;
use Illuminate\Contracts\Config\Repository;
use Toby\Domain\Enums\VacationType;
class VacationTypeConfigRetriever
{
public const KEY_TECHNICAL_APPROVAL = "technical_approval";
public const KEY_ADMINISTRATIVE_APPROVAL = "administrative_approval";
public const KEY_BILLABLE = "billable";
public const KEY_HAS_LIMIT = "has_limit";
public function __construct(
protected Repository $config,
) {}
public function needsTechnicalApproval(VacationType $type): bool
{
return $this->getConfigFor($type)[static::KEY_TECHNICAL_APPROVAL];
}
public function needsAdministrativeApproval(VacationType $type): bool
{
return $this->getConfigFor($type)[static::KEY_ADMINISTRATIVE_APPROVAL];
}
public function isBillable(VacationType $type): bool
{
return $this->getConfigFor($type)[static::KEY_BILLABLE];
}
public function hasLimit(VacationType $type): bool
{
return $this->getConfigFor($type)[static::KEY_HAS_LIMIT];
}
protected function getConfigFor(VacationType $type): array
{
return $this->config->get("vacation_types.{$type->value}");
}
}