Completed
Push — develop ( 2cda13...a5c8cc )
by
unknown
10s
created

BuiltInToken::getRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright 2018 SURFnet bv
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Surfnet\StepupSelfService\SelfServiceBundle\Value;
20
21
use Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException;
22
23
class BuiltInToken implements AvailableTokenInterface
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
24
{
25
    private $supportedTypes = [
26
        'sms' => [
27
            'loaLevel' => 2,
28
            'route' => 'ss_registration_sms_send_challenge'
29
        ],
30
        'u2f' => [
31
            'loaLevel' => 3,
32
            'route' => 'ss_registration_u2f_registration'
33
        ],
34
        'yubikey' => [
35
            'loaLevel' => 3,
36
            'route' => 'ss_registration_yubikey_prove_possession'
37
        ],
38
    ];
39
40
    private $type;
41
42
    /**
43
     * @param $type
44
     * @return BuiltInToken
45
     */
46
    public static function fromSecondFactorType($type)
47
    {
48
        return new self($type);
49
    }
50
51
    private function __construct($type)
52
    {
53
        if (!isset($this->supportedTypes[$type])) {
54
            throw InvalidArgumentException::invalidType('valid second factor type', 'type', $type);
55
        }
56
        $this->type = $type;
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getRoute()
63
    {
64
        return $this->supportedTypes[$this->type]['route'];
65
    }
66
67
    /**
68
     * @return mixed
69
     */
70
    public function getType()
71
    {
72
        return $this->type;
73
    }
74
75
    /**
76
     * @return int
77
     */
78
    public function getLoaLevel()
79
    {
80
        return $this->supportedTypes[$this->type]['loaLevel'];
81
    }
82
83
    /**
84
     * @return boolean
85
     */
86
    public function isGssp()
87
    {
88
        return false;
89
    }
90
}
91