This commit is contained in:
Adrian Hopek
2022-04-05 14:21:32 +02:00
parent 3ab02f1df4
commit 5122b5b70b
13 changed files with 157 additions and 31 deletions

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Toby\Domain;
use Illuminate\Contracts\Config\Repository;
use Toby\Domain\Enums\EmploymentForm;
use Toby\Domain\Enums\VacationType;
class VacationTypeConfigRetriever
@@ -13,6 +14,7 @@ class VacationTypeConfigRetriever
public const KEY_ADMINISTRATIVE_APPROVAL = "administrative_approval";
public const KEY_BILLABLE = "billable";
public const KEY_HAS_LIMIT = "has_limit";
public const KEY_AVAILABLE_FOR = "available_for";
public function __construct(
protected Repository $config,
@@ -38,6 +40,11 @@ class VacationTypeConfigRetriever
return $this->getConfigFor($type)[static::KEY_HAS_LIMIT];
}
public function isAvailableFor(VacationType $type, EmploymentForm $employmentForm): bool
{
return in_array($employmentForm, $this->getConfigFor($type)[static::KEY_AVAILABLE_FOR], true);
}
protected function getConfigFor(VacationType $type): array
{
return $this->config->get("vacation_types.{$type->value}");