Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
21 | public static function create(string $name, array $options = []): StrategyInterface |
||
22 | { |
||
23 | if (false !== $class = StrategyRegistry::getClassByName($name)) { |
||
24 | /** @var StrategyInterface $instance */ |
||
25 | $instance = new $class; |
||
26 | if ($instance instanceof SetOptionsInterface) { |
||
27 | $instance->setOptions($options); |
||
28 | } |
||
29 | |||
30 | return $instance; |
||
31 | |||
32 | } |
||
33 | |||
34 | throw new \RuntimeException('Unsupported strategy name.'); |
||
35 | } |
||
36 | } |