VettedSecondFactor   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 88
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 3 1
A getIdentifier() 0 3 1
A getId() 0 3 1
A create() 0 15 1
A applyIdentityForgottenEvent() 0 5 1
A vettingType() 0 3 1
A __construct() 0 2 1
A complyWithRevocation() 0 10 1
A revoke() 0 9 1
1
<?php
2
3
/**
4
 * Copyright 2014 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
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in file comment
Loading history...
18
19
namespace Surfnet\Stepup\Identity\Entity;
20
21
use Surfnet\Stepup\Identity\Api\Identity;
22
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
23
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
24
use Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent;
25
use Surfnet\Stepup\Identity\Value\IdentityId;
26
use Surfnet\Stepup\Identity\Value\SecondFactorId;
27
use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
28
use Surfnet\Stepup\Identity\Value\VettingType;
29
use Surfnet\StepupBundle\Value\SecondFactorType;
30
31
/**
32
 * A second factor whose possession and its Registrant's identity has been vetted by a Registration Authority.
33
 *
34
 * @SuppressWarnings("PHPMD.UnusedPrivateFields")
35
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
36
class VettedSecondFactor extends AbstractSecondFactor
37
{
38
    private ?Identity $identity = null;
39
40
    private ?SecondFactorId $id = null;
41
42
    private ?SecondFactorType $type = null;
43
44
    /**
45
     * @var SecondFactorIdentifier
46
     */
47
    private SecondFactorIdentifier $secondFactorIdentifier;
48
49
    private ?VettingType $vettingType = null;
50
51
    public static function create(
52
        SecondFactorId $id,
53
        Identity $identity,
54
        SecondFactorType $type,
55
        SecondFactorIdentifier $secondFactorIdentifier,
56
        VettingType $vettingType,
57
    ): self {
58
        $secondFactor = new self();
59
        $secondFactor->id = $id;
60
        $secondFactor->identity = $identity;
61
        $secondFactor->type = $type;
62
        $secondFactor->secondFactorIdentifier = $secondFactorIdentifier;
63
        $secondFactor->vettingType = $vettingType;
64
65
        return $secondFactor;
66
    }
67
68
    final public function __construct()
69
    {
70
    }
71
72
    public function getId(): ?SecondFactorId
73
    {
74
        return $this->id;
75
    }
76
77
    public function revoke(): void
78
    {
79
        $this->apply(
80
            new VettedSecondFactorRevokedEvent(
81
                $this->identity->getId(),
0 ignored issues
show
Bug introduced by
The method getId() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
                $this->identity->/** @scrutinizer ignore-call */ 
82
                                 getId(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
82
                $this->identity->getInstitution(),
83
                $this->id,
0 ignored issues
show
Bug introduced by
It seems like $this->id can also be of type null; however, parameter $secondFactorId of Surfnet\Stepup\Identity\...kedEvent::__construct() does only seem to accept Surfnet\Stepup\Identity\Value\SecondFactorId, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

83
                /** @scrutinizer ignore-type */ $this->id,
Loading history...
84
                $this->type,
0 ignored issues
show
Bug introduced by
It seems like $this->type can also be of type null; however, parameter $secondFactorType of Surfnet\Stepup\Identity\...kedEvent::__construct() does only seem to accept Surfnet\StepupBundle\Value\SecondFactorType, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

84
                /** @scrutinizer ignore-type */ $this->type,
Loading history...
85
                $this->secondFactorIdentifier,
86
            ),
87
        );
88
    }
89
90
    public function complyWithRevocation(IdentityId $authorityId): void
91
    {
92
        $this->apply(
93
            new CompliedWithVettedSecondFactorRevocationEvent(
94
                $this->identity->getId(),
95
                $this->identity->getInstitution(),
96
                $this->id,
0 ignored issues
show
Bug introduced by
It seems like $this->id can also be of type null; however, parameter $secondFactorId of Surfnet\Stepup\Identity\...ionEvent::__construct() does only seem to accept Surfnet\Stepup\Identity\Value\SecondFactorId, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

96
                /** @scrutinizer ignore-type */ $this->id,
Loading history...
97
                $this->type,
0 ignored issues
show
Bug introduced by
It seems like $this->type can also be of type null; however, parameter $secondFactorType of Surfnet\Stepup\Identity\...ionEvent::__construct() does only seem to accept Surfnet\StepupBundle\Value\SecondFactorType, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

97
                /** @scrutinizer ignore-type */ $this->type,
Loading history...
98
                $this->secondFactorIdentifier,
99
                $authorityId,
100
            ),
101
        );
102
    }
103
104
    public function vettingType(): VettingType
105
    {
106
        return $this->vettingType;
107
    }
108
109
    protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

109
    protected function applyIdentityForgottenEvent(/** @scrutinizer ignore-unused */ IdentityForgottenEvent $event): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
110
    {
111
        $secondFactorIdentifierClass = $this->secondFactorIdentifier::class;
112
113
        $this->secondFactorIdentifier = $secondFactorIdentifierClass::unknown();
114
    }
115
116
    public function getType(): SecondFactorType
117
    {
118
        return $this->type;
119
    }
120
121
    public function getIdentifier(): SecondFactorIdentifier
122
    {
123
        return $this->secondFactorIdentifier;
124
    }
125
}
126