Laravel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getVocabularyDirectories() 0 3 1
A get() 0 3 1
A finalizeConfigKey() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliqArts\DirectTranslator\ConfigProvider;
6
7
use ReliqArts\DirectTranslator\ConfigProvider;
8
9
class Laravel implements ConfigProvider
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function get(string $key, $default = null)
15
    {
16
        return config($key, $default);
17
    }
18
19
    /**
20
     * @return array
21
     */
22
    public function getVocabularyDirectories(): array
23
    {
24
        return config($this->finalizeConfigKey(static::CONFIG_KEY_VOCABULARY_DIRECTORIES), []);
25
    }
26
27
    /**
28
     * Ensure config key is package specific.
29
     *
30
     * @param $key
31
     *
32
     * @return string
33
     */
34
    private function finalizeConfigKey($key): string
35
    {
36
        if (strpos($key, static::CONFIG_KEY_PACKAGE) === 0) {
37
            return $key;
38
        }
39
40
        return sprintf('%s.%s', static::CONFIG_KEY_PACKAGE, $key);
41
    }
42
}
43