Conditions | 5 |
Paths | 7 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
36 | public function getInstance($currency) |
||
37 | { |
||
38 | $connectors = $this->connectors; |
||
39 | if ($connectors) { |
||
40 | $supported_currencies = []; |
||
41 | $instance = []; |
||
42 | |||
43 | foreach ($connectors as $connector) { |
||
44 | $connector->setCurrency($currency); |
||
45 | $supported_currencies = array_merge($supported_currencies, $connector->supported_currencies); |
||
46 | |||
47 | if (in_array($currency, $connector->supported_currencies)) { |
||
48 | $instance = $connector; |
||
49 | } |
||
50 | } |
||
51 | |||
52 | if ($instance) { |
||
53 | return $instance; |
||
54 | } |
||
55 | |||
56 | $supported_currencies = implode(', ', $supported_currencies); |
||
57 | |||
58 | throw new Exception('"'.$currency.'" cryptocurrency is not supported now! Currently available values: '.$supported_currencies); |
||
59 | } |
||
62 |