Completed
Push — main ( ded6f8...f0aa9e )
by Johan
15s
created

MockSecondFactor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 9
dl 0
loc 11
rs 10
c 1
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Copyright 2025 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
 */
20
21
namespace Surfnet\StepupGateway\Behat\Mock;
22
23
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
24
use Surfnet\StepupBundle\Value\Loa;
25
use Surfnet\StepupGateway\GatewayBundle\Service\SecondFactor\SecondFactorInterface;
26
27
readonly class MockSecondFactor implements SecondFactorInterface
28
{
29
    public function __construct(
30
        public string $id,
31
        public string $identityId,
32
        public string $nameId,
33
        public string $institution,
34
        public string $displayLocale,
35
        public string $secondFactorId,
36
        public string $secondFactorType,
37
        public string $secondFactorIdentifier,
38
        public bool $identityVetted = true,
39
    ) {
40
    }
41
42
43
    public function canSatisfy(Loa $loa, SecondFactorTypeService $service): bool
0 ignored issues
show
Unused Code introduced by
The parameter $loa 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

43
    public function canSatisfy(/** @scrutinizer ignore-unused */ Loa $loa, SecondFactorTypeService $service): bool

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...
Unused Code introduced by
The parameter $service 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

43
    public function canSatisfy(Loa $loa, /** @scrutinizer ignore-unused */ SecondFactorTypeService $service): bool

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...
44
    {
45
        return true;
46
    }
47
48
    public function getLoaLevel(SecondFactorTypeService $service): float
0 ignored issues
show
Unused Code introduced by
The parameter $service 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

48
    public function getLoaLevel(/** @scrutinizer ignore-unused */ SecondFactorTypeService $service): float

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...
49
    {
50
        return 2.0;
51
    }
52
53
    public function getSecondFactorId(): string
54
    {
55
        return $this->secondFactorId;
56
    }
57
58
    public function getSecondFactorType(): string
59
    {
60
        return $this->secondFactorType;
61
    }
62
63
    public function getDisplayLocale(): string
64
    {
65
        return $this->displayLocale;
66
    }
67
68
    public function getSecondFactorIdentifier(): string
69
    {
70
        return $this->secondFactorIdentifier;
71
    }
72
73
    public function getInstitution(): string
74
    {
75
        return 'inst-mock';
76
    }
77
}
78