KeyLoader::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Acquia\Hmac;
4
5
/**
6
 * KeyLoader class for loading keys.
7
 *
8
 * These keys can be later used for signing and verifying requests.
9
 */
10
class KeyLoader implements KeyLoaderInterface
11
{
12
    /**
13
     * @var array
14
     *   Array of provided keys.
15
     */
16
    protected $keys = [];
17
18
    /**
19
     * Initialize keys with provided pairs.
20
     *   @param array $keys
21
     */
22 4
    public function __construct(array $keys = [])
23
    {
24 4
        $this->keys = $keys;
25 4
    }
26
27
    /**
28
     * {@inheritDoc}
29
     */
30 2
    public function load($id)
31
    {
32 2
        if (!isset($this->keys[$id])) {
33 1
            return false;
34
        }
35
36 1
        return new Key($id, $this->keys[$id]);
37
    }
38
}
39