Test Failed
Branch backend-2.5 (785da6)
by Jonathan
15:44 queued 34s
created

ReportingCloud::setDefaultSettings()   A

Complexity

Conditions 6
Paths 32

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 24
ccs 13
cts 13
cp 1
rs 9.2222
c 0
b 0
f 0
cc 6
nc 32
nop 0
crap 6
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://github.com/TextControl/txtextcontrol-reportingcloud-php for the canonical source repository
11
 * @license   https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-php/master/LICENSE.md
12
 * @copyright © 2019 Text Control GmbH
13
 */
14
15
namespace TxTextControl\ReportingCloud;
16
17
/**
18
 * Class ReportingCloud
19
 *
20
 * @package TxTextControl\ReportingCloud
21
 * @author  Jonathan Maron (@JonathanMaron)
22
 */
23
class ReportingCloud extends AbstractReportingCloud
24
{
25
    use BuildTrait;
26
    use DeleteTrait;
27
    use GetTrait;
28
    use PostTrait;
29
    use PutTrait;
30
31
    // <editor-fold desc="Methods">
32
33
    /**
34
     * ReportingCloud constructor
35
     *
36
     * @param array|null $options
37
     */
38 283
    public function __construct(?array $options = null)
39
    {
40 283
        if (is_array($options)) {
41
42
            $methods = [
43
                // Credentials
44 274
                'api_key'  => 'setApiKey',
45
                // Credentials (deprecated, use 'api_key' only)
46
                'username' => 'setUsername',
47
                'password' => 'setPassword',
48
                // Options
49
                'base_uri' => 'setBaseUri',
50
                'debug'    => 'setDebug',
51
                'test'     => 'setTest',
52
                'timeout'  => 'setTimeout',
53
                'version'  => 'setVersion',
54
            ];
55
56 274
            foreach ($methods as $key => $method) {
57 274
                if (array_key_exists($key, $options)) {
58 274
                    $this->$method($options[$key]);
59
                }
60
            }
61
        }
62
63 283
        $this->setDefaultOptions();
64 283
    }
65
66
    // </editor-fold>
67
}
68