KeyLoader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 7 2
A __construct() 0 3 1
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