-
Notifications
You must be signed in to change notification settings - Fork 2
/
OnOff.php
35 lines (27 loc) · 958 Bytes
/
OnOff.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace Trompette\FeatureToggles\OnOffStrategy;
use Trompette\FeatureToggles\TogglingStrategy;
final class OnOff implements TogglingStrategy
{
private ConfigurationRepository $configurationRepository;
public function __construct(ConfigurationRepository $configurationRepository)
{
$this->configurationRepository = $configurationRepository;
}
public function getConfiguration(string $feature): array
{
return ['enabled' => $this->configurationRepository->isEnabled($feature)];
}
public function decideIfTargetHasFeature(string $target, string $feature): bool
{
return $this->configurationRepository->isEnabled($feature);
}
public function on(string $feature): void
{
$this->configurationRepository->setEnabled(true, $feature);
}
public function off(string $feature): void
{
$this->configurationRepository->setEnabled(false, $feature);
}
}