WrapIt   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 7
c 3
b 0
f 0
lcom 0
cbo 2
dl 0
loc 57
ccs 26
cts 26
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getClientId() 0 3 1
A getClientSecret() 0 3 1
A getDomain() 0 3 1
B __construct() 0 30 4
1
<?php
2
3
namespace WrapIt;
4
5
use WrapIt\Exceptions\WrapItParameterException;
6
use WrapIt\Http\WrapItApiRequester;
7
use WrapIt\Helpers\WrapItLoginHelper;
8
9
/**
10
 * Class WrapIt
11
 *
12
 * @package WrapIt
13
 */
14
class WrapIt {
15
16
    private $config;
17
18
    private $server_uri;
19
20
    private $sdk_version = "0.1";
0 ignored issues
show
Unused Code introduced by
The property $sdk_version is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
21
    private $public_key = null;
22
    private $private_key = null;
23
    private $domain = null;
24
25
    private $requester = null;
26
27 78
    public function __construct($config) {
28 78
        $this->config = array_merge(array(
29 78
            "domain" => null,
30 39
            "client_id" => null,
31
            "client_secret" => null
32 78
        ), $config);
33
34 78
        if ($this->config["domain"] == null) {
35 12
            throw new WrapItParameterException("config[domain] is required but missing");
36
        }
37
38 66
        if ($this->config["client_id"] == null) {
39 12
            throw new WrapItParameterException("config[client_id] is required but missing");
40
        }
41
42 54
        if ($this->config["client_secret"] == null) {
43 6
            throw new WrapItParameterException("config[client_secret] is required but missing");
44
        }
45
46 48
        $this->config["domain"] = str_replace("https://", "", $this->config["domain"]);
47 48
        $this->config["domain"] = str_replace("http://", "", $this->config["domain"]);
48 48
        $this->config["domain"] = rtrim($this->config["domain"], "/");
49 48
        $this->server_uri = "https://" . $this->config["domain"];
50
51 48
        $this->domain = $this->config["domain"];
52 48
        $this->public_key = $this->config["client_id"];
53 48
        $this->private_key = $this->config["client_secret"];
54
55 48
        $this->requester = new WrapItApiRequester($this->config["domain"]);
56 48
    }
57
58 42
    public function getClientId() {
59 42
        return $this->public_key;
60
    }
61
62 36
    public function getClientSecret() {
63 36
        return $this->private_key;
64
    }
65
66 36
    public function getDomain() {
67 36
        return $this->domain;
68
    }
69
70
}
71