IndexEndpointResolver   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 27.27%

Importance

Changes 0
Metric Value
dl 0
loc 30
c 0
b 0
f 0
wmc 6
lcom 0
cbo 3
ccs 3
cts 11
cp 0.2727
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B resolve() 0 21 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\Endpoint;
13
14
use LightSaml\Model\Metadata\EndpointReference;
15
use LightSaml\Model\Metadata\IndexedEndpoint;
16
use LightSaml\Resolver\Endpoint\Criteria\IndexCriteria;
17
use LightSaml\Criteria\CriteriaSet;
18
19
class IndexEndpointResolver implements EndpointResolverInterface
20
{
21
    /**
22
     * @param CriteriaSet         $criteriaSet
23
     * @param EndpointReference[] $candidates
24
     *
25
     * @return EndpointReference[]
26
     */
27 2
    public function resolve(CriteriaSet $criteriaSet, array $candidates)
28
    {
29 2
        if (false === $criteriaSet->has(IndexCriteria::class)) {
30 2
            return $candidates;
31
        }
32
33
        $result = array();
34
        /** @var IndexCriteria $indexCriteria */
35
        foreach ($criteriaSet->get(IndexCriteria::class) as $indexCriteria) {
36
            foreach ($candidates as $endpointReference) {
37
                $endpoint = $endpointReference->getEndpoint();
38
                if ($endpoint instanceof IndexedEndpoint) {
39
                    if ($endpoint->getIndex() == $indexCriteria->getIndex()) {
40
                        $result[] = $endpointReference;
41
                    }
42
                }
43
            }
44
        }
45
46
        return $result;
47
    }
48
}
49