VerificationResult   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 78
Duplicated Lines 30.77 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 24
loc 78
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A verificationSucceeded() 12 12 2
A noSuchProcedure() 0 7 1
A verificationFailed() 12 12 2
A isSuccess() 0 4 2
A didVerificationSucceed() 0 4 1
A getProcedureId() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
 */
18
19
namespace Surfnet\StepupRa\RaBundle\Service\Gssf;
20
21
use Surfnet\StepupRa\RaBundle\Exception\InvalidArgumentException;
22
23
final class VerificationResult
24
{
25
    /**
26
     * @var boolean
27
     */
28
    private $verificationSucceeded;
29
30
    /**
31
     * @var string|null
32
     */
33
    private $procedureId;
34
35
    /**
36
     * @param string $procedureId
37
     * @return VerificationResult
38
     */
39 View Code Duplication
    public static function verificationSucceeded($procedureId)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        if (!is_string($procedureId)) {
42
            throw InvalidArgumentException::invalidType('string', 'procedureId', $procedureId);
43
        }
44
45
        $result = new self();
46
        $result->verificationSucceeded = true;
47
        $result->procedureId = $procedureId;
48
49
        return $result;
50
    }
51
52
    public static function noSuchProcedure()
53
    {
54
        $result = new self();
55
        $result->verificationSucceeded = false;
56
57
        return $result;
58
    }
59
60
    /**
61
     * @param string $procedureId
62
     * @return VerificationResult
63
     */
64 View Code Duplication
    public static function verificationFailed($procedureId)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66
        if (!is_string($procedureId)) {
67
            throw InvalidArgumentException::invalidType('string', 'procedureId', $procedureId);
68
        }
69
70
        $result = new self();
71
        $result->verificationSucceeded = false;
72
        $result->procedureId = $procedureId;
73
74
        return $result;
75
    }
76
77
    /**
78
     * @return bool
79
     */
80
    public function isSuccess()
81
    {
82
        return $this->verificationSucceeded && $this->procedureId;
83
    }
84
85
    /**
86
     * @return bool
87
     */
88
    public function didVerificationSucceed()
89
    {
90
        return $this->verificationSucceeded;
91
    }
92
93
    /**
94
     * @return null|string NULL if no procedure ID was known for given SAML request ID.
95
     */
96
    public function getProcedureId()
97
    {
98
        return $this->procedureId;
99
    }
100
}
101