GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 36987f...5a4612 )
by François
03:22
created

IPv6::parseConfig()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.2
cc 4
eloc 8
nc 5
nop 1
1
<?php
2
/**
3
 * Copyright 2015 François Kooman <[email protected]>.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace fkooman\VPN\Server\Config;
19
20
class IPv6
21
{
22
    /** @var string */
23
    private $prefix;
24
25
    /** @var array */
26
    private $dns;
27
28
    public function __construct(array $input)
29
    {
30
        $this->parseConfig($input);
31
    }
32
33
    public function getPrefix()
34
    {
35
        return $this->prefix;
36
    }
37
38
    public function getDns()
39
    {
40
        return $this->dns;
41
    }
42
43
    /**
44
     * Parse and validate the configuration and set default values if they
45
     * are missing from the configuration file.
46
     */
47
    private function parseConfig(array $input)
48
    {
49
        foreach (['prefix'] as $k) {
50
            if (!array_key_exists($k, $input)) {
51
                throw new RuntimeException(sprintf('missing key "%s" in configuration', $k));
52
            }
53
        }
54
        $this->prefix = $input['prefix'];
55
56
        if (!array_key_exists('dns', $input)) {
57
            $input['dns'] = ['2001:4860:4860::8888', '2001:4860:4860::8844'];
58
        }
59
        $this->dns = $input['dns'];
60
    }
61
}
62