Completed
Push — master ( 7c178f...a26768 )
by Westin
14s queued 12s
created

Config   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 40
ccs 16
cts 16
cp 1
rs 10
c 1
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getNamespace() 0 3 1
A getOptions() 0 3 1
A getPrefix() 0 3 1
A getLoggerServiceName() 0 3 1
A getType() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11PhpCache\Config;
6
7
use WShafer\PSR11PhpCache\Exception\MissingCacheConfigException;
8
9
class Config
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $config = [];
15
16 10
    public function __construct(array $config = [])
17
    {
18 10
        $this->config = $config;
19 10
    }
20
21 2
    public function getType()
22
    {
23 2
        $type = $this->config['type'] ?? '';
24 2
        if (empty($type)) {
25 1
            throw new MissingCacheConfigException('type is missing from cache config');
26
        }
27
28 1
        return $type;
29
    }
30
31 2
    public function getOptions(): array
32
    {
33 2
        return $this->config['options'] ?? [];
34
    }
35
36 2
    public function getNamespace(): ?string
37
    {
38 2
        return $this->config['namespace'] ?? null;
39
    }
40
41 2
    public function getPrefix(): ?string
42
    {
43 2
        return $this->config['prefix'] ?? null;
44
    }
45
46 2
    public function getLoggerServiceName(): ?string
47
    {
48 2
        return $this->config['logger'] ?? null;
49
    }
50
}
51