LocaleConfig::getOptionOrConfig()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 2
nc 2
nop 2
1
<?php
2
3
namespace CaribouFute\LocaleRoute;
4
5
use Illuminate\Config\Repository as Config;
6
7
class LocaleConfig
8
{
9
    protected $config;
10
11
    public function __construct(Config $config)
12
    {
13
        $this->config = $config;
14
    }
15
16
    public function locales(array $options = [])
17
    {
18
        return $this->getOptionOrConfig('locales', $options);
19
    }
20
21
    protected function getOptionOrConfig(string $key, array $options)
22
    {
23
        return isset($options[$key]) ?
24
            $options[$key] :
25
            $this->getConfig($key);
26
    }
27
28
    public function getConfig(string $key)
29
    {
30
        return $this->config->get('localeroute.' . $key);
31
    }
32
33
    public function addLocaleToUrl(array $options = [])
34
    {
35
        return $this->getOptionOrConfig('add_locale_to_url', $options);
36
    }
37
}
38