GsspToken::getLoaLevel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
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\SamlStepupProviderBundle\Provider\ViewConfig;
24
use Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException;
25
26
readonly class GsspToken implements AvailableTokenInterface
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class GsspToken
Loading history...
27
{
28
    public static function fromViewConfig(ViewConfig $viewConfig, string $type): self
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function fromViewConfig()
Loading history...
29
    {
30
        if ($type === '') {
31
            throw InvalidArgumentException::invalidType('a non empty string', 'type', $type);
32
        }
33
34
        return new self($viewConfig, $type);
35
    }
36
37
38
    private function __construct(private ViewConfig $viewConfig, private string $type)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
39
    {
40
    }
41
42
    public function getRoute(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getRoute()
Loading history...
43
    {
44
        return 'ss_registration_gssf_authenticate';
45
    }
46
47
    public function getType(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getType()
Loading history...
48
    {
49
        return $this->type;
50
    }
51
52
    public function getLoaLevel(): int
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getLoaLevel()
Loading history...
53
    {
54
        return (int) $this->viewConfig->getLoa();
55
    }
56
57
    public function isGssp(): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function isGssp()
Loading history...
58
    {
59
        return true;
60
    }
61
62
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
63
     * @return array<string, string> The route parameters for the GSSP token.
64
     */
65
    public function getRouteParams(): array
66
    {
67
        return [
68
            'provider' => $this->type,
69
        ];
70
    }
71
72
    public function getViewConfig(): ViewConfig
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getViewConfig()
Loading history...
73
    {
74
        return $this->viewConfig;
75
    }
76
}
77