KeyLoader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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