Completed
Push — master ( 4e360d...80bc96 )
by Daan van
07:27
created

SubjectConfirmationRecipientMatches   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 25.93 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 4
lcom 1
cbo 3
dl 7
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 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
namespace SAML2\Assertion\Validation\ConstraintValidator;
4
5
use SAML2\Assertion\Validation\Result;
6
use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
7
use SAML2\Configuration\Destination;
8
use SAML2\XML\saml\SubjectConfirmation;
9
10
class SubjectConfirmationRecipientMatches implements
11
    SubjectConfirmationConstraintValidator
12
{
13
    /**
14
     * @var \SAML2\Configuration\Destination
15
     */
16
    private $destination;
17
18
    public function __construct(Destination $destination)
19
    {
20
        $this->destination = $destination;
21
    }
22
23
    public function validate(
24
        SubjectConfirmation $subjectConfirmation,
25
        Result $result
26
    ) {
27
        $recipient = $subjectConfirmation->SubjectConfirmationData->Recipient;
28 View Code Duplication
        if ($recipient && !$this->destination->equals(new Destination($recipient))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
29
            $result->addError(sprintf(
30
                'Recipient in SubjectConfirmationData ("%s") does not match the current destination ("%s")',
31
                $recipient,
32
                $this->destination
33
            ));
34
        }
35
    }
36
}
37