AlgorithmFilterResolver   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 30%

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
wmc 8
lcom 0
cbo 5
ccs 3
cts 10
cp 0.3
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B resolve() 0 20 8
1
<?php
2
3
/*
4
 * This file is part of the LightSAML-Core package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Resolver\Credential;
13
14
use LightSaml\Credential\CredentialInterface;
15
use LightSaml\Credential\Criteria\AlgorithmCriteria;
16
use LightSaml\Criteria\CriteriaSet;
17
18
class AlgorithmFilterResolver extends AbstractQueryableResolver
19
{
20
    /**
21
     * @param CriteriaSet           $criteriaSet
22
     * @param CredentialInterface[] $arrCredentials
23
     *
24
     * @return CredentialInterface[]
25
     */
26 10
    public function resolve(CriteriaSet $criteriaSet, array $arrCredentials = array())
27
    {
28 10
        if (false == $criteriaSet->has(AlgorithmCriteria::class)) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
29 10
            return $arrCredentials;
30
        }
31
32
        $result = array();
33
        foreach ($criteriaSet->get(AlgorithmCriteria::class) as $criteria) {
34
            /* @var AlgorithmCriteria $criteria */
35
            foreach ($arrCredentials as $credential) {
36
                if (($credential->getPrivateKey() && $credential->getPrivateKey()->getAlgorith() == $criteria->getAlgorithm()) ||
0 ignored issues
show
Deprecated Code introduced by
The method RobRichards\XMLSecLibs\X...urityKey::getAlgorith() has been deprecated.

This method has been deprecated.

Loading history...
37
                    ($credential->getPublicKey() && $credential->getPublicKey()->getAlgorith() == $criteria->getAlgorithm())
0 ignored issues
show
Deprecated Code introduced by
The method RobRichards\XMLSecLibs\X...urityKey::getAlgorith() has been deprecated.

This method has been deprecated.

Loading history...
38
                ) {
39
                    $result[] = $credential;
40
                }
41
            }
42
        }
43
44
        return $result;
45
    }
46
}
47