Passed
Branch master (d23cf5)
by Jonathan
22:25 queued 01:36
created

ReportingCloud::__construct()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 24
ccs 16
cts 16
cp 1
rs 9.7998
cc 4
nc 4
nop 1
crap 4
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * ReportingCloud PHP SDK
6
 *
7
 * PHP SDK for ReportingCloud Web API. Authored and supported by Text Control GmbH.
8
 *
9
 * @link      https://www.reporting.cloud to learn more about ReportingCloud
10
 * @link      https://git.io/Jejj2 for the canonical source repository
11
 * @license   https://git.io/Jejjr
12
 * @copyright © 2023 Text Control GmbH
13
 */
14
15
namespace TextControl\ReportingCloud;
16
17
class ReportingCloud extends AbstractReportingCloud
18
{
19
    use BuildTrait;
20
    use DeleteTrait;
21
    use GetTrait;
22
    use PostTrait;
23
    use PutTrait;
24
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
            }
50
        }
51
    }
52
}
53