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

ConfigurationKeyRepository::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 3
crap 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