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