Laravel::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
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