Passed
Branch master (d8ab5e)
by Max
05:15 queued 02:56
created

BasicConfig   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 81
ccs 19
cts 19
cp 1
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setDefaultView() 0 5 1
A setDictionaryConfig() 0 5 1
A getCache() 0 3 1
A addCache() 0 5 1
A getDefaultView() 0 3 1
A getDefaultDictionaryClass() 0 3 1
A getDefaultDataProviderClass() 0 3 1
A getDictionaryConfig() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EasyDictionary;
6
7
use EasyDictionary\DataProvider\Simple as SimpleDataProvider;
8
use EasyDictionary\Dictionary\Simple as SimpleDictionary;
9
use EasyDictionary\Interfaces\ConfigInterface;
10
use Psr\SimpleCache\CacheInterface;
11
12
/**
13
 * Class BasicConfig
14
 *
15
 * @package EasyDictionary\Dictionary
16
 */
17
class BasicConfig implements ConfigInterface
18
{
19
    protected $defaultDataProviderClass = SimpleDataProvider::class;
20
    protected $defaultDictionaryClass = SimpleDictionary::class;
21
    protected $dictionaryConfig = [];
22
    protected $defaultView = null;
23
    protected $caches = [];
24
25
    /**
26
     * @return string
27
     */
28 1
    public function getDefaultDataProviderClass(): string
29
    {
30 1
        return $this->defaultDataProviderClass;
31
    }
32
33
    /**
34
     * @return string
35
     */
36 1
    public function getDefaultDictionaryClass(): string
37
    {
38 1
        return $this->defaultDictionaryClass;
39
    }
40
41
    /**
42
     * @return array
43
     */
44 1
    public function getDictionaryConfig(): array
45
    {
46 1
        return $this->dictionaryConfig;
47
    }
48
49
    /**
50
     * @param array $dictionaryConfig
51
     * @return $this
52
     */
53 1
    public function setDictionaryConfig(array $dictionaryConfig)
54
    {
55 1
        $this->dictionaryConfig = $dictionaryConfig;
56
57 1
        return $this;
58
    }
59
60
    /**
61
     * @return callable
62
     */
63 1
    public function getDefaultView(): ?callable
64
    {
65 1
        return $this->defaultView;
66
    }
67
68
    /**
69
     * @param callable $view
70
     * @return $this
71
     */
72 1
    public function setDefaultView(callable $view)
73
    {
74 1
        $this->defaultView = $view;
75
76 1
        return $this;
77
    }
78
79
    /**
80
     * @param string $name
81
     * @return null|CacheInterface
82
     */
83 1
    public function getCache(string $name): ?CacheInterface
84
    {
85 1
        return $this->caches[$name] ?? null;
86
    }
87
88
    /**
89
     * @param CacheInterface $cache
90
     * @param string $name
91
     * @return $this
92
     */
93 1
    public function addCache(CacheInterface $cache, string $name)
94
    {
95 1
        $this->caches[$name] = $cache;
96
97 1
        return $this;
98
    }
99
}
100