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 ( a4ad96...a25367 )
by François
02:17
created

UserConfig::setDisable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
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
use fkooman\VPN\Server\InputValidation;
21
22
class UserConfig
23
{
24
    /** @var bool */
25
    private $disable;
26
27
    /** @var string|false */
28
    private $otpSecret;
29
30
    public function __construct(array $configData)
31
    {
32
        $disable = array_key_exists('disable', $configData) ? $configData['disable'] : false;
33
        InputValidation::disable($disable);
34
        $this->disable = $disable;
35
36
        $otpSecret = array_key_exists('otp_secret', $configData) ? $configData['otp_secret'] : false;
37
        if (!is_bool($otpSecret)) {
38
            InputValidation::otpSecret($otpSecret);
39
        }
40
        $this->otpSecret = $otpSecret;
41
    }
42
43
    public function getDisable()
44
    {
45
        return $this->disable;
46
    }
47
48
    public function setDisable($disable)
49
    {
50
        InputValidation::disable($disable);
51
        $this->disable = $disable;
52
    }
53
54
    public function getOtpSecret()
55
    {
56
        return $this->otpSecret;
57
    }
58
59
    /**
60
     * Hide the OTP secret by setting it to 'true' if a secret is set, or leave
61
     * it 'false' when no OTP secret was set.
62
     */
63
    public function hideOtpSecret()
64
    {
65
        if (false !== $this->otpSecret) {
66
            $this->otpSecret = true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type string|false of property $otpSecret.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
67
        }
68
    }
69
70
    public function setOtpSecret($otpSecret)
71
    {
72
        InputValidation::otpSecret($otpSecret);
73
        $this->otpSecret = $otpSecret;
74
    }
75
76
    public function toArray()
77
    {
78
        return [
79
            'disable' => $this->disable,
80
            'otp_secret' => $this->otpSecret,
81
        ];
82
    }
83
}
84