BuiltInToken::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Copyright 2018 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\Value;
22
23
use Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException;
24
25
class BuiltInToken implements AvailableTokenInterface
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class BuiltInToken
Loading history...
26
{
27
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
28
     * @var array<string, array<string, int|string>>
29
     */
30
    private array $supportedTypes = [
0 ignored issues
show
Coding Style introduced by
Private member variable "supportedTypes" must be prefixed with an underscore
Loading history...
31
        'sms' => [
32
            'loaLevel' => 2,
33
            'route' => 'ss_registration_sms_send_challenge'
34
        ],
35
        'yubikey' => [
36
            'loaLevel' => 3,
37
            'route' => 'ss_registration_yubikey_prove_possession'
38
        ],
39
    ];
40
41
    public static function fromSecondFactorType(string $type): self
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function fromSecondFactorType()
Loading history...
42
    {
43
        return new self($type);
44
    }
45
46
    private function __construct(private readonly string $type)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
47
    {
48
        if (!isset($this->supportedTypes[$type])) {
49
            throw InvalidArgumentException::invalidType('Invalid second factor type', 'type', $type);
50
        }
51
    }
52
    public function getRoute(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getRoute()
Loading history...
53
    {
54
        return $this->supportedTypes[$this->type]['route'];
55
    }
56
57
58
    public function getType(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getType()
Loading history...
59
    {
60
        return $this->type;
61
    }
62
63
    public function getLoaLevel(): int
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getLoaLevel()
Loading history...
64
    {
65
        return $this->supportedTypes[$this->type]['loaLevel'];
66
    }
67
68
    public function isGssp(): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function isGssp()
Loading history...
69
    {
70
        return false;
71
    }
72
}
73