| Total Complexity | 8 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | final class ManagedSettings implements SettingsInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var SettingsInterface[] |
||
| 13 | */ |
||
| 14 | private $repos; |
||
| 15 | |||
| 16 | public function __construct(SettingsInterface ...$settings) |
||
| 17 | { |
||
| 18 | $this->repos = $settings; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function loadSettings(SettingsInterface $repo): void |
||
| 24 | } |
||
| 25 | |||
| 26 | public function getSetting(string $name) |
||
| 27 | { |
||
| 28 | foreach ($this->repos as $repo) { |
||
| 29 | if ($repo->hasSetting($name)) { |
||
| 30 | return $repo->getSetting($name); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | throw new UnknownSettingException("Unknown setting '$name'"); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function hasSetting(string $name): bool |
||
| 46 | } |
||
| 47 | } |
||
| 48 |