CompositeCredentialStore   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getByEntityId() 0 8 2
A add() 0 5 1
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\Store\Credential;
13
14
use LightSaml\Credential\CredentialInterface;
15
16
class CompositeCredentialStore implements CredentialStoreInterface
17
{
18
    /** @var CredentialStoreInterface[] */
19
    protected $stores = [];
20
21
    /**
22
     * @param string $entityId
23
     *
24
     * @return CredentialInterface[]
25
     */
26
    public function getByEntityId($entityId)
27
    {
28
        $result = [];
29
        foreach ($this->stores as $store) {
30
            $result = array_merge($result, $store->getByEntityId($entityId));
31
        }
32
33
        return $result;
34
    }
35
36
    /**
37
     * @return CompositeCredentialStore
38
     */
39
    public function add(CredentialStoreInterface $store)
40
    {
41
        $this->stores[] = $store;
42
43
        return $this;
44
    }
45
}
46