|
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
|
|
|
$disable = array_key_exists('otpSecret', $configData) ? $configData['otpSecret'] : false; |
|
|
|
|
|
|
37
|
|
|
// XXX: InputValidation::otpSecret($otpSecret); |
|
|
|
|
|
|
38
|
|
|
$this->otpSecret = $otpSecret; |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getDisable() |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->disable; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getOtpSecret() |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->otpSecret; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function toArray() |
|
52
|
|
|
{ |
|
53
|
|
|
return [ |
|
54
|
|
|
'disable' => $this->disable, |
|
55
|
|
|
'otpSecret' => $this->otpSecret, |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.