Total Complexity | 4 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class TopProvider |
||
8 | { |
||
9 | /** @var TopStrategyInterface[] */ |
||
10 | private array $strategies = []; |
||
11 | |||
12 | |||
13 | public function getStrategy(string $name): TopStrategyInterface |
||
14 | { |
||
15 | foreach ($this->strategies as $strategy) { |
||
16 | if ($strategy->supports($name)) { |
||
17 | return $strategy; |
||
18 | } |
||
19 | } |
||
20 | |||
21 | throw new \DomainException(sprintf('Unable to find a strategy to type [%s]', $name)); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @param TopStrategyInterface $strategy |
||
26 | */ |
||
27 | public function addStrategy(TopStrategyInterface $strategy): void |
||
30 | } |
||
31 | } |
||
32 |