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

KeyManager::GetServerKey()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 2
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
}