Configurable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
dl 0
loc 44
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 3 1
A setConfig() 0 9 2
A addDefaultConfig() 0 5 1
1
<?php
2
3
namespace Ghc\Rosetta;
4
5
use Illuminate\Config\Repository;
6
7
trait Configurable
8
{
9
    /**
10
     * Configuration options.
11
     *
12
     * @var Repository
13
     */
14
    protected $config;
15
16
    /**
17
     * @return array
18
     */
19
    public function getConfig()
20
    {
21
        return $this->config->all();
22
    }
23
24
    /**
25
     * @param array|string $config
26
     * @param mixed        $value
27
     *
28
     * @return self
29
     */
30
    public function setConfig($config, $value = null)
31
    {
32
        if (is_string($config)) {
33
            $this->config->set($config, $value);
34
        } else {
35
            $this->config = new Repository($config);
36
        }
37
38
        return $this;
39
    }
40
41
    /**
42
     * @param array $config
43
     *
44
     * @return self
45
     */
46
    protected function addDefaultConfig($config)
47
    {
48
        $this->setConfig(array_merge($config, $this->getConfig()));
49
50
        return $this;
51
    }
52
}
53