VettingTypeCollection   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
c 2
b 0
f 0
dl 0
loc 44
rs 10
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A allowSelfVetting() 0 3 1
A add() 0 3 1
A allowSelfAssertedTokens() 0 3 1
A expressVettingPreference() 0 13 5
A isPreferred() 0 6 2
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\Value\VettingType;
22
23
use Surfnet\StepupSelfService\SelfServiceBundle\Value\ActivationFlowPreferenceInterface;
24
25
class VettingTypeCollection
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class VettingTypeCollection
Loading history...
26
{
27
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
28
     * @var VettingTypeInterface[]
29
     */
30
    private array $collection = [];
0 ignored issues
show
Coding Style introduced by
Private member variable "collection" must be prefixed with an underscore
Loading history...
31
32
    public function add(VettingTypeInterface $vettingType): void
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function add()
Loading history...
33
    {
34
        $this->collection[$vettingType->identifier()] = $vettingType;
35
    }
36
37
    public function expressVettingPreference(ActivationFlowPreferenceInterface $preference): void
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function expressVettingPreference()
Loading history...
38
    {
39
        switch ((string) $preference) {
40
            case 'ra':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
41
                if (array_key_exists(VettingTypeInterface::ON_PREMISE, $this->collection)) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
42
                    $this->collection[VettingTypeInterface::ON_PREMISE]->setPrefered();
43
                }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
44
                break;
45
            case 'self':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
46
                if (array_key_exists(VettingTypeInterface::SELF_ASSERTED_TOKENS, $this->collection)) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
47
                    $this->collection[VettingTypeInterface::SELF_ASSERTED_TOKENS]->setPrefered();
48
                }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
49
                break;
50
        }
51
    }
52
53
    public function allowSelfVetting(): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function allowSelfVetting()
Loading history...
54
    {
55
        return array_key_exists(VettingTypeInterface::SELF_VET, $this->collection);
56
    }
57
58
    public function allowSelfAssertedTokens(): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function allowSelfAssertedTokens()
Loading history...
59
    {
60
        return array_key_exists(VettingTypeInterface::SELF_ASSERTED_TOKENS, $this->collection);
61
    }
62
63
    public function isPreferred(string $vettingType): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function isPreferred()
Loading history...
64
    {
65
        if (!array_key_exists($vettingType, $this->collection)) {
66
            return false;
67
        }
68
        return $this->collection[$vettingType]->isPrefered();
69
    }
70
}
71