Completed
Push — AddActivityLog ( afa80e...195157 )
by D.
45:05 queued 35:04
created

ConfigAbstract::implementAllowable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: sdibble
5
 * Date: 12/7/2016
6
 * Time: 2:25 PM.
7
 */
8
9
namespace SET\Handlers\DBConfigs;
10
11
/**
12
 * Class ConfigAbstract.
13
 */
14
abstract class ConfigAbstract
15
{
16
    /**
17
     * @var array
18
     */
19
    public $settings;
20
21
    public $allowable;
22
23
    /**
24
     * ConfigAbstract constructor.
25
     *
26
     * @param array $settings
27
     */
28
    public function __construct($settings = [])
29
    {
30
        $this->settings = $settings;
31
    }
32
33
    public function implementAllowable()
34
    {
35
        foreach ($this->allowable as $configKey) {
36
            $this->setConfigValues($configKey);
37
        }
38
    }
39
40
    /**
41
     * All classes need to setup some kind of configuration data.
42
     *
43
     * @return mixed
44
     */
45
    abstract public function setup();
46
47
    /**
48
     * First we set the value stored in the database. If there is no value, we go to what is in the config/env files.
49
     *
50
     * @param string $location
51
     * @param mixed  $default
52
     */
53
    public function setConfigValues(string $location, $default = null)
54
    {
55
        $value = $default ?? $this->settings[$location] ?? config($location);
56
        config([$location => $value]);
57
    }
58
}
59