Passed
Push — master ( 6ef306...d2de8d )
by Bence
04:24
created

KeyManager::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
crap 1
1
<?php
2
3
namespace CSFCloud;
4
5
use CSFCloud\Exceptions\MissingServerKeyException;
6
7
class KeyManager {
8
9
    private $server_key = null;
10
    private $client_id = null;
11
    private $client_secret = null;
12
13 6
    public function __construct(array $options) {
14 6
        $options = array_merge([
15 6
            "key" => null,
16
            "client_id" => null,
17
            "client_secret" => null
18 6
        ], $options);
19
20 6
        $this->server_key = $options["key"];
21 6
        $this->client_id = $options["client_id"];
22 6
        $this->client_secret = $options["client_secret"];
23 6
    }
24
25 6
    public function GetServerKey() : string {
26 6
        if (!$this->server_key) {
27 2
            throw new MissingServerKeyException();
28
        }
29 4
        return $this->server_key;
30
    }
31
32
}