Total Complexity | 3 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | class OptimusFactory |
||
20 | { |
||
21 | /** |
||
22 | * Make a new Optimus client. |
||
23 | * |
||
24 | * @param array $config |
||
25 | * @return \Jenssegers\Optimus\Optimus |
||
26 | */ |
||
27 | public function make(array $config): Optimus |
||
28 | { |
||
29 | $config = $this->getConfig($config); |
||
30 | |||
31 | return $this->getClient($config); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Get the configuration data. |
||
36 | * |
||
37 | * @param array $config |
||
38 | * @return array |
||
39 | * |
||
40 | * @throws \InvalidArgumentException |
||
41 | */ |
||
42 | protected function getConfig(array $config): array |
||
43 | { |
||
44 | return [ |
||
45 | 'prime' => Arr::get($config, 'prime', 0), |
||
46 | 'inverse' => Arr::get($config, 'inverse', 0), |
||
47 | 'random' => Arr::get($config, 'random', 0), |
||
48 | ]; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Get the optimus client. |
||
53 | * |
||
54 | * @param array $config |
||
55 | * @return \Jenssegers\Optimus\Optimus |
||
56 | */ |
||
57 | protected function getClient(array $config): Optimus |
||
60 | } |
||
61 | } |
||
62 |