CompositeCredentialStore::getByEntityId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 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