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

KeyManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 23
rs 10
c 0
b 0
f 0
ccs 12
cts 12
cp 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A GetServerKey() 0 5 2
A __construct() 0 10 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
}