Conditions | 4 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
22 | 145 | public static function getCalculator(): CalculatorInterface |
|
23 | { |
||
24 | 145 | if (null !== self::$calculator) { |
|
25 | 143 | return self::$calculator; |
|
26 | } |
||
27 | 2 | foreach (self::$calculators as $calculator) { |
|
28 | /** @var CalculatorInterface $calculator */ |
||
29 | 1 | if ($calculator::supported()) { |
|
30 | return |
||
31 | 1 | self::$calculator = new $calculator(); |
|
32 | } |
||
33 | } |
||
34 | |||
35 | 1 | throw new \RuntimeException('Cannot find calculator for money calculations.'); |
|
36 | } |
||
51 |