CredentialNameFilterResolver   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 23.08%

Importance

Changes 0
Metric Value
dl 0
loc 32
c 0
b 0
f 0
wmc 6
lcom 0
cbo 4
ccs 3
cts 13
cp 0.2308
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B resolve() 0 23 6
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\CredentialNameCriteria;
16
use LightSaml\Criteria\CriteriaSet;
17
18
class CredentialNameFilterResolver 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(CredentialNameCriteria::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(CredentialNameCriteria::class) as $criteria) {
34
            /* @var CredentialNameCriteria $criteria */
35
            foreach ($arrCredentials as $credential) {
36
                $arrCredentialNames = $credential->getKeyNames();
37
                $criteriaName = $criteria->getName();
38
                foreach ($arrCredentialNames as $credentialName) {
39
                    if ($credentialName == $criteriaName) {
40
                        $result[] = $credential;
41
                        break;
42
                    }
43
                }
44
            }
45
        }
46
47
        return $result;
48
    }
49
}
50