ProofOfPossessionResult::didOtpVerificationFail()   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 2014 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\Service\YubikeySecondFactor;
22
23
use Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException;
24
25
final class ProofOfPossessionResult
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ProofOfPossessionResult
Loading history...
26
{
27
    /**
28
     * The ID of the second factor that has been proven to be in possession of the registrant.
29
     *
30
     * @var string|null A UUID or null.
31
     */
32
    private ?string $secondFactorId = null;
0 ignored issues
show
Coding Style introduced by
Private member variable "secondFactorId" must be prefixed with an underscore
Loading history...
33
34
    private bool $otpInvalid = false;
0 ignored issues
show
Coding Style introduced by
Private member variable "otpInvalid" must be prefixed with an underscore
Loading history...
35
36
    private bool $otpVerificationFailed = false;
0 ignored issues
show
Coding Style introduced by
Private member variable "otpVerificationFailed" must be prefixed with an underscore
Loading history...
37
38
    private bool $proofOfPossessionFailed = false;
0 ignored issues
show
Coding Style introduced by
Private member variable "proofOfPossessionFailed" must be prefixed with an underscore
Loading history...
39
40
    private function __construct()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
41
    {
42
    }
43
44
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
45
     * @return ProofOfPossessionResult
46
     */
47
    public static function invalidOtp(): self
48
    {
49
        $result = new self();
50
        $result->otpInvalid = true;
51
52
        return $result;
53
    }
54
55
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
56
     * @return ProofOfPossessionResult
57
     */
58
    public static function otpVerificationFailed(): self
59
    {
60
        $result = new self();
61
        $result->otpVerificationFailed = true;
62
63
        return $result;
64
    }
65
66
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
67
     * @return ProofOfPossessionResult
68
     */
69
    public static function proofOfPossessionCommandFailed(): self
70
    {
71
        $result = new self();
72
        $result->proofOfPossessionFailed = true;
73
74
        return $result;
75
    }
76
77
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
78
     * @param string $secondFactorId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
79
     * @return ProofOfPossessionResult
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
80
     */
81
    public static function secondFactorCreated($secondFactorId): self
82
    {
83
        if (!is_string($secondFactorId)) {
0 ignored issues
show
introduced by
The condition is_string($secondFactorId) is always true.
Loading history...
84
            throw InvalidArgumentException::invalidType('string', 'secondFactorId', $secondFactorId);
85
        }
86
87
        $result = new self();
88
        $result->secondFactorId = $secondFactorId;
89
90
        return $result;
91
    }
92
93
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
94
     * @return bool
95
     */
96
    public function isSuccessful(): bool
97
    {
98
        return $this->secondFactorId !== null;
99
    }
100
101
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
102
     * @return string
103
     */
104
    public function getSecondFactorId(): ?string
105
    {
106
        return $this->secondFactorId;
107
    }
108
109
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
110
     * @return bool
111
     */
112
    public function isOtpInvalid(): bool
113
    {
114
        return $this->otpInvalid;
115
    }
116
117
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
118
     * @return boolean
119
     */
120
    public function didOtpVerificationFail(): bool
121
    {
122
        return $this->otpVerificationFailed;
123
    }
124
125
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
126
     * @return boolean
127
     */
128
    public function didProofOfPossessionCommandFail(): bool
129
    {
130
        return $this->proofOfPossessionFailed;
131
    }
132
}
133