Completed
Push — master ( 5acd24...5c27f0 )
by John
14s
created

ConfigurationKeyRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
1
<?php
2
namespace LunixREST\Server\AccessControl\KeyRepository;
3
4
use LunixREST\Configuration\Configuration;
5
6
/**
7
 * An array key repository that is read from a configuration key.
8
 * Class ConfigurationKeyRepository
9
 * @package LunixREST\Server\AccessControl\KeyRepository
10
 */
11
class ConfigurationKeyRepository extends ArrayKeyRepository
12
{
13
    /**
14
     * @param Configuration $config a config that has a list of valid keys in the stored $configKey
15
     * @param $namespace
16
     * @param string $configKey key to use when accessing the list of valid keys from the $config
17
     */
18 4
    public function __construct(Configuration $config, string $namespace, string $configKey = 'keys')
19
    {
20 4
        $keys = [];
21 4
        if($config->has($configKey, $namespace)){
22 4
            $configKeys = $config->get($configKey, $namespace);
23 4
            if(is_array($configKeys)) {
24 4
                $keys = $configKeys;
25
            }
26
        }
27
28 4
        parent::__construct($keys);
29 4
    }
30
}
31