| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public static function getAdapter(string $adapterType, array $config, Client $client): Adapter |
||
| 16 | { |
||
| 17 | if (!array_key_exists($adapterType, self::$adapters)) { |
||
| 18 | throw new \RuntimeException("The adapter type $adapterType is not know. Allowed types are " . implode(', ', array_keys(self::$adapters)) . '.'); |
||
| 19 | } |
||
| 20 | |||
| 21 | $adapterClass = self::$adapters[$adapterType]; |
||
| 22 | |||
| 23 | /** @var Adapter $adapter */ |
||
| 24 | $adapter = call_user_func([$adapterClass, 'fromConfigArray'], $config, $client); |
||
| 25 | |||
| 26 | if ($adapter instanceof ClientAwareAdapter) { |
||
| 27 | $adapter->setClient($client); |
||
| 28 | } |
||
| 29 | |||
| 30 | return $adapter; |
||
| 31 | } |
||
| 33 |