Passed
Push — master ( 535bb2...af76a1 )
by Alexis
02:02
created

Options::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace AWurth\Config;
4
5
class Options
6
{
7
    /**
8
     * @var bool
9
     */
10
    protected $enableImports;
11
12
    /**
13
     * @var bool
14
     */
15
    protected $enableParameters;
16
17
    /**
18
     * @var string
19
     */
20
    protected $importsKey;
21
22
    /**
23
     * @var string
24
     */
25
    protected $parametersKey;
26
27
    /**
28
     * Constructor.
29
     *
30
     * @param array $options
31
     */
32
    public function __construct(array $options = [])
33
    {
34
        $config = array_replace([
35
            'enable_imports' => true,
36
            'enable_parameters' => true,
37
            'imports_key' => 'imports',
38
            'parameters_key' => 'parameters'
39
        ], $options);
40
41
        $this->enableImports = $config['enable_imports'];
42
        $this->enableParameters = $config['enable_parameters'];
43
        $this->importsKey = $config['imports_key'];
44
        $this->parametersKey = $config['parameters_key'];
45
    }
46
47
    /**
48
     * Tells whether imports are enabled.
49
     *
50
     * @return bool
51
     */
52
    public function areImportsEnabled()
53
    {
54
        return $this->enableImports;
55
    }
56
57
    /**
58
     * Sets whether to enable imports.
59
     *
60
     * @param bool $enabled
61
     *
62
     * @return self
63
     */
64
    public function setEnableImports($enabled)
65
    {
66
        $this->enableImports = $enabled;
67
68
        return $this;
69
    }
70
71
    /**
72
     * Tells whether parameters are enabled.
73
     *
74
     * @return bool
75
     */
76
    public function areParametersEnabled()
77
    {
78
        return $this->enableParameters;
79
    }
80
81
    /**
82
     *
83
     * Sets whether to enable parameters.
84
     *
85
     * @param bool $enabled
86
     *
87
     * @return self
88
     */
89
    public function setEnableParameters($enabled)
90
    {
91
        $this->enableParameters = $enabled;
92
93
        return $this;
94
    }
95
96
    /**
97
     * Gets the imports key.
98
     *
99
     * @return string
100
     */
101
    public function getImportsKey()
102
    {
103
        return $this->importsKey;
104
    }
105
106
    /**
107
     * Sets the imports key.
108
     *
109
     * @param string $importsKey
110
     *
111
     * @return self
112
     */
113
    public function setImportsKey($importsKey)
114
    {
115
        $this->importsKey = $importsKey;
116
117
        return $this;
118
    }
119
120
    /**
121
     * Gets the parameters key.
122
     *
123
     * @return string
124
     */
125
    public function getParametersKey()
126
    {
127
        return $this->parametersKey;
128
    }
129
130
    /**
131
     * Sets the parameters key.
132
     *
133
     * @param string $parametersKey
134
     *
135
     * @return self
136
     */
137
    public function setParametersKey($parametersKey)
138
    {
139
        $this->parametersKey = $parametersKey;
140
141
        return $this;
142
    }
143
}
144