Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | 186 | public function __construct(array $options = []) |
|
26 | { |
||
27 | 186 | if ([] === $options) { |
|
28 | 18 | return; |
|
29 | } |
||
30 | |||
31 | 180 | $methods = [ |
|
32 | // Credentials |
||
33 | 180 | 'api_key' => 'setApiKey', |
|
34 | // Credentials (deprecated, use 'api_key' only) |
||
35 | 180 | 'username' => 'setUsername', |
|
36 | 180 | 'password' => 'setPassword', |
|
37 | // Options |
||
38 | 180 | 'base_uri' => 'setBaseUri', |
|
39 | 180 | 'debug' => 'setDebug', |
|
40 | 180 | 'test' => 'setTest', |
|
41 | 180 | 'timeout' => 'setTimeout', |
|
42 | 180 | 'version' => 'setVersion', |
|
43 | 180 | ]; |
|
44 | |||
45 | 180 | foreach ($methods as $key => $method) { |
|
46 | 180 | if (array_key_exists($key, $options)) { |
|
47 | // @phpstan-ignore-next-line |
||
48 | 180 | $this->{$method}($options[$key]); |
|
49 | } |
||
53 |