Configurable::addDefaultConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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