LocaleConfig   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 9
c 1
b 0
f 0
dl 0
loc 29
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A locales() 0 3 1
A getOptionOrConfig() 0 5 2
A __construct() 0 3 1
A getConfig() 0 3 1
A addLocaleToUrl() 0 3 1
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