Completed
Push — master ( 230528...f44b8d )
by Sebastian
15:53 queued 31s
created

Configuration::getColors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
ccs 1
cts 1
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace phpbu\App;
3
4
/**
5
 * Configuration
6
 *
7
 * @package    phpbu
8
 * @subpackage App
9
 * @author     Sebastian Feldmann <[email protected]>
10
 * @copyright  Sebastian Feldmann <[email protected]>
11
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
12
 * @link       http://phpbu.de/
13
 * @since      Class available since Release 1.0.0
14
 */
15
class Configuration
16
{
17
    /**
18
     * Filename
19
     *
20
     * @var string
21
     */
22
    private $filename;
23
24
    /**
25
     * Working directory
26
     *
27
     * @var string
28
     */
29
    private $workingDirectory;
30
31
    /**
32
     * Path to bootstrap file.
33
     *
34
     * @var string
35
     */
36
    private $bootstrap;
37
38
    /**
39
     * Verbose output
40
     *
41
     * @var bool
42
     */
43
    private $verbose = false;
44
45
    /**
46
     * Use colors in output.
47
     *
48
     * @var bool
49
     */
50
    private $colors = false;
51
52
    /**
53
     * Output debug information
54
     *
55
     * @var boolean
56
     */
57
    private $debug = false;
58
59
    /**
60
     * Don't execute anything just pretend to
61
     *
62
     * @var bool
63
     */
64
    private $simulate = false;
65
66
    /**
67
     * List of include paths
68
     *
69
     * @var array
70
     */
71
    private $includePaths = [];
72
73
    /**
74
     * List of ini settings
75
     *
76
     * @var array
77
     */
78
    private $iniSettings = [];
79
80
    /**
81
     * List of logger configurations
82
     *
83
     * @var array
84
     */
85
    private $loggers = [];
86
87
    /**
88
     * List of backup configurations
89
     *
90
     * @var array
91
     */
92 33
    private $backups = [];
93
94 33
    /**
95 33
     * Constructor
96
     *
97
     * @param string $wd
98
     */
99
    public function __construct($wd = null)
100
    {
101
        $this->workingDirectory = $wd === null ? getcwd() : $wd;
102 24
    }
103
104 24
    /**
105 24
     * Filename setter.
106 24
     *
107
     * @param string $file
108
     */
109
    public function setFilename($file)
110
    {
111
        $this->filename         = $file;
112
        $this->workingDirectory = dirname($file);
113 1
    }
114
115 1
    /**
116
     * Filename getter.
117
     *
118
     * @return string
119
     */
120
    public function getFilename()
121
    {
122
        return $this->filename;
123 1
    }
124
125 1
    /**
126 1
     * Working directory setter.
127
     *
128
     * @param string $wd
129
     */
130
    public function setWorkingDirectory($wd)
131
    {
132
        $this->workingDirectory = $wd;
133 2
    }
134
135 2
    /**
136
     * Working directory getter.
137
     *
138
     * @return string
139
     */
140
    public function getWorkingDirectory()
141
    {
142
        return $this->workingDirectory;
143 14
    }
144
145 14
    /**
146 14
     * Bootstrap setter.
147
     *
148
     * @param $file
149
     */
150
    public function setBootstrap($file)
151
    {
152
        $this->bootstrap = $file;
153 2
    }
154
155 2
    /**
156
     * Bootstrap getter.
157
     *
158
     * @return string
159
     */
160
    public function getBootstrap()
161
    {
162
        return $this->bootstrap;
163 14
    }
164
165 14
    /**
166 14
     * Verbose setter.
167
     *
168
     * @param bool $bool
169
     */
170
    public function setVerbose($bool)
171
    {
172
        $this->verbose = $bool;
173 2
    }
174
175 2
    /**
176
     * Verbose getter.
177
     *
178
     * @return bool
179
     */
180
    public function getVerbose()
181
    {
182
        return $this->verbose;
183 14
    }
184
185 14
    /**
186 14
     * Colors setter.
187
     *
188
     * @param bool $bool
189
     */
190
    public function setColors($bool)
191
    {
192
        $this->colors = $bool;
193 2
    }
194
195 2
    /**
196
     * Colors getter.
197
     *
198
     * @return bool
199
     */
200
    public function getColors()
201
    {
202
        return $this->colors;
203 2
    }
204
205 2
    /**
206 2
     * Debug setter.
207
     *
208
     * @param bool $bool
209
     */
210
    public function setDebug($bool)
211
    {
212
        $this->debug = $bool;
213 2
    }
214
215 2
    /**
216
     * Debug getter.
217
     *
218
     * @return bool
219
     */
220
    public function getDebug()
221
    {
222
        return $this->debug;
223 12
    }
224
225 12
    /**
226 12
     * Simulate setter.
227
     *
228
     * @param bool $bool
229
     */
230
    public function setSimulate($bool)
231
    {
232
        $this->simulate = $bool;
233 3
    }
234
235 3
    /**
236
     * Simulate getter.
237
     *
238
     * @return bool
239
     */
240
    public function isSimulation()
241
    {
242
        return $this->simulate;
243
    }
244 12
245
    /**
246 12
     * Add an include_path.
247 12
     *
248
     * @param string $path
249
     */
250
    public function addIncludePath($path)
251
    {
252
        $this->includePaths[] = $path;
253
    }
254 3
255
    /**
256 3
     * Get the list of include path.
257
     *
258
     * @return array
259
     */
260
    public function getIncludePaths()
261
    {
262
        return $this->includePaths;
263
    }
264
265
    /**
266 13
     * Add a ini settings.
267
     *
268 13
     * @param string $name
269 1
     * @param string $value
270
     */
271 12
    public function addIniSetting($name, $value)
272 12
    {
273
        $this->iniSettings[$name] = $value;
274
    }
275
276
    /**
277
     * Get the list of ini settings.
278
     *
279 4
     * @return array
280
     */
281 4
    public function getIniSettings()
282
    {
283
        return $this->iniSettings;
284
    }
285
286
    /**
287
     * Add a logger.
288
     * This accepts valid logger configs as well as valid Listener objects.
289 7
     *
290
     * @param  mixed $logger
291 7
     * @throws \phpbu\App\Exception
292 7
     */
293
    public function addLogger($logger)
294
    {
295
        if (!is_a($logger, '\\phpbu\\App\\Listener') && !is_a($logger, '\\phpbu\\App\\Configuration\\Logger')) {
296
            throw new Exception('invalid logger, only \'Listener\' and valid logger configurations are accepted');
297
        }
298
        $this->loggers[] = $logger;
299 3
    }
300
301 3
    /**
302
     * Get the list of logger configurations.
303
     *
304
     * @return array
305
     */
306
    public function getLoggers()
307
    {
308
        return $this->loggers;
309
    }
310
311
    /**
312
     * Add a Backup configuration.
313
     *
314
     * @param \phpbu\App\Configuration\Backup $backup
315
     */
316
    public function addBackup(Configuration\Backup $backup)
317
    {
318
        $this->backups[] = $backup;
319
    }
320
321
    /**
322
     * Get the list of backup configurations.
323
     *
324
     * @return array
325
     */
326
    public function getBackups()
327
    {
328
        return $this->backups;
329
    }
330
}
331