RecoveryTokenConfig   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 23
rs 10
c 1
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isSmsDisabled() 0 3 1
A isSafeStoreCodeDisabled() 0 3 1
A __construct() 0 7 3
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Copyright 2022 SURFnet bv
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *     http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
20
21
namespace Surfnet\StepupSelfService\SelfServiceBundle\Service\SelfAssertedTokens;
22
23
use Surfnet\StepupSelfService\SelfServiceBundle\Service\SelfAssertedTokens\Exception\RecoveryTokenConfigurationException;
24
25
class RecoveryTokenConfig
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class RecoveryTokenConfig
Loading history...
26
{
27
    private readonly bool $smsEnabled;
0 ignored issues
show
Coding Style introduced by
Private member variable "smsEnabled" must be prefixed with an underscore
Loading history...
28
29
    private readonly bool $safeStoreCodeEnabled;
0 ignored issues
show
Coding Style introduced by
Private member variable "safeStoreCodeEnabled" must be prefixed with an underscore
Loading history...
30
31
    public function __construct(bool $smsEnabled, bool $safeStoreCodeEnabled)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
32
    {
33
        if ($smsEnabled === false && $safeStoreCodeEnabled === false) {
34
            throw new RecoveryTokenConfigurationException('The SMS or safe-store code recovery token must be enabled');
35
        }
36
        $this->smsEnabled = $smsEnabled;
0 ignored issues
show
Bug introduced by
The property smsEnabled is declared read-only in Surfnet\StepupSelfServic...ens\RecoveryTokenConfig.
Loading history...
37
        $this->safeStoreCodeEnabled = $safeStoreCodeEnabled;
0 ignored issues
show
Bug introduced by
The property safeStoreCodeEnabled is declared read-only in Surfnet\StepupSelfServic...ens\RecoveryTokenConfig.
Loading history...
38
    }
39
40
    public function isSmsDisabled(): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function isSmsDisabled()
Loading history...
41
    {
42
        return !$this->smsEnabled;
43
    }
44
45
    public function isSafeStoreCodeDisabled(): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function isSafeStoreCodeDisabled()
Loading history...
46
    {
47
        return !$this->safeStoreCodeEnabled;
48
    }
49
}
50