DebuggerOptions   A
last analyzed

Complexity

Total Complexity 35

Size/Duplication

Total Lines 447
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 35
lcom 2
cbo 2
dl 0
loc 447
rs 9.6
c 0
b 0
f 0

33 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 4 1
A setEnabled() 0 5 1
A isDisabled() 0 4 1
A getMode() 0 4 1
A setMode() 0 5 2
A hasBar() 0 4 1
A setBar() 0 5 1
A getBarPanels() 0 4 1
A setBarPanels() 0 5 1
A getCssFiles() 0 4 1
A setCssFiles() 0 5 1
A getJsFiles() 0 4 1
A setJsFiles() 0 5 1
A getBarInfo() 0 4 1
A setBarInfo() 0 5 1
A getStrict() 0 4 1
A setStrict() 0 5 1
A getLog() 0 7 2
A setLog() 0 5 1
A getEmail() 0 4 1
A setEmail() 0 5 1
A getMaxDepth() 0 4 1
A setMaxDepth() 0 5 1
A getMaxLength() 0 4 1
A setMaxLength() 0 5 1
A getBarTitle() 0 4 1
A setBarTitle() 0 5 1
A hasBarNoLogo() 0 4 1
A setBarNoLogo() 0 5 1
A hasBarNoClose() 0 4 1
A setBarNoClose() 0 5 1
A hasFireLogger() 0 4 1
A setFireLogger() 0 5 1
1
<?php
2
/**
3
 * Webino (http://webino.sk/)
4
 *
5
 * @link        https://github.com/webino/WebinoDebug/ for the canonical source repository
6
 * @copyright   Copyright (c) 2014-2018 Webino, s. r. o. (http://webino.sk/)
7
 * @license     BSD-3-Clause
8
 */
9
10
namespace WebinoDebug\Options;
11
12
use WebinoDebug\Debugger;
13
use Zend\Stdlib\AbstractOptions;
14
use Zend\Stdlib\ArrayUtils;
15
16
/**
17
 * Class DebuggerOptions
18
 */
19
class DebuggerOptions extends AbstractOptions
20
{
21
    /**
22
     * @var bool
23
     */
24
    protected $enabled = true;
25
26
    /**
27
     * @var bool|null
28
     */
29
    protected $mode = null;
30
31
    /**
32
     * @var bool
33
     */
34
    protected $bar = false;
35
36
    /**
37
     * @var string
38
     */
39
    protected $barTitle;
40
41
    /**
42
     * @var array
43
     */
44
    protected $barInfo = [];
45
46
    /**
47
     * @var array
48
     */
49
    protected $barPanels = [
50
        'WebinoDebug:info'     => Debugger\InfoPanel::class,
51
        'WebinoDebug:timer'    => Debugger\TimerPanel::class,
52
        'WebinoDebug:config'   => Debugger\ConfigPanel::class,
53
        'WebinoDebug:services' => Debugger\ServicesPanel::class,
54
        'WebinoDebug:events'   => Debugger\EventPanel::class,
55
    ];
56
57
    /**
58
     * @var array
59
     */
60
    protected $cssFiles = [__DIR__ . '/../../../data/assets/Debugger/style.css'];
61
62
    /**
63
     * @var array
64
     */
65
    protected $jsFiles = [__DIR__ . '/../../../data/assets/Debugger/script.js'];
66
67
    /**
68
     * @var int
69
     */
70
    protected $strict = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED & ~E_USER_NOTICE;
71
72
    /**
73
     * @var string|null
74
     */
75
    protected $log;
76
77
    /**
78
     * @var string
79
     */
80
    protected $email = '';
81
82
    /**
83
     * @var int
84
     */
85
    protected $maxDepth = 10;
86
87
    /**
88
     * @var int
89
     */
90
    protected $maxLength = 300;
91
92
    /**
93
     * @var bool
94
     */
95
    protected $barNoLogo = false;
96
97
    /**
98
     * @var bool
99
     */
100
    protected $barNoClose = false;
101
102
    /**
103
     * @var bool
104
     */
105
    protected $fireLogger = false;
106
107
    /**
108
     * Is debugger enabled?
109
     *
110
     * @return bool
111
     */
112
    public function isEnabled(): bool
113
    {
114
        return $this->enabled;
115
    }
116
117
    /**
118
     * Enable debugger
119
     *
120
     * @param bool $enabled
121
     * @return $this
122
     */
123
    public function setEnabled($enabled = true)
124
    {
125
        $this->enabled = (bool) $enabled;
126
        return $this;
127
    }
128
129
    /**
130
     * Is debugger disabled?
131
     *
132
     * @return bool
133
     */
134
    public function isDisabled(): bool
135
    {
136
        return !$this->enabled;
137
    }
138
139
    /**
140
     * Debugger mode
141
     *
142
     * true  = production|false
143
     * false = development|null
144
     * null  = autodetect|IP address(es) csv/array
145
     *
146
     * @return bool|null
147
     */
148
    public function getMode(): ?bool
149
    {
150
        return $this->mode;
151
    }
152
153
    /**
154
     * Debugger mode, production or development.
155
     *
156
     * @param bool|null $mode
157
     * @return $this
158
     */
159
    public function setMode($mode)
160
    {
161
        $this->mode = (null === $mode ? null : (bool) $mode);
162
        return $this;
163
    }
164
165
    /**
166
     * Is debugger bar enabled?
167
     *
168
     * @return bool
169
     */
170
    public function hasBar(): bool
171
    {
172
        return $this->bar;
173
    }
174
175
    /**
176
     * Toggle debugger bar
177
     *
178
     * @param bool $bar
179
     * @return $this
180
     */
181
    public function setBar($bar)
182
    {
183
        $this->bar = (bool) $bar;
184
        return $this;
185
    }
186
187
    /**
188
     * Debugger bar panels
189
     *
190
     * @return array
191
     */
192
    public function getBarPanels(): array
193
    {
194
        return $this->barPanels;
195
    }
196
197
    /**
198
     * Set custom debugger bar panels
199
     *
200
     * @param array $barPanels
201
     * @return $this
202
     */
203
    public function setBarPanels(array $barPanels)
204
    {
205
        $this->barPanels = ArrayUtils::merge($this->barPanels, $barPanels);
206
        return $this;
207
    }
208
209
    /**
210
     * @return array
211
     */
212
    public function getCssFiles(): array
213
    {
214
        return $this->cssFiles;
215
    }
216
217
    /**
218
     * Set custom CSS files
219
     *
220
     * @param array $cssFiles
221
     * @return $this
222
     */
223
    public function setCssFiles(array $cssFiles)
224
    {
225
        $this->cssFiles = ArrayUtils::merge($this->cssFiles, $cssFiles);
226
        return $this;
227
    }
228
229
    /**
230
     * @return array
231
     */
232
    public function getJsFiles(): array
233
    {
234
        return $this->jsFiles;
235
    }
236
237
    /**
238
     * Set custom Javascript files
239
     *
240
     * @param array $jsFiles
241
     * @return $this
242
     */
243
    public function setJsFiles(array $jsFiles)
244
    {
245
        $this->jsFiles = ArrayUtils::merge($this->jsFiles, $jsFiles);
246
        return $this;
247
    }
248
249
    /**
250
     * Return custom debugger bar info
251
     *
252
     * @return array
253
     */
254
    public function getBarInfo(): array
255
    {
256
        return $this->barInfo;
257
    }
258
259
    /**
260
     * Set custom debugger bar info
261
     *
262
     * @param array $barInfo
263
     * @return $this
264
     */
265
    public function setBarInfo(array $barInfo)
266
    {
267
        $this->barInfo = ArrayUtils::merge($this->barInfo, $barInfo);
268
        return $this;
269
    }
270
271
    /**
272
     * Error reporting level
273
     *
274
     * @return int
275
     */
276
    public function getStrict(): int
277
    {
278
        return $this->strict;
279
    }
280
281
    /**
282
     * Set error reporting level
283
     *
284
     * @param int $strict
285
     * @return $this
286
     */
287
    public function setStrict($strict)
288
    {
289
        $this->strict = (int) $strict;
290
        return $this;
291
    }
292
293
    /**
294
     * @return string Empty string to disable, null for default
295
     */
296
    public function getLog(): string
297
    {
298
        if (null === $this->log) {
299
            $this->setLog('data/log');
300
        }
301
        return $this->log;
302
    }
303
304
    /**
305
     * Path to log directory
306
     *
307
     * @param string $log
308
     * @return $this
309
     */
310
    public function setLog($log)
311
    {
312
        $this->log = realpath($log);
313
        return $this;
314
    }
315
316
    /**
317
     * Administrator address
318
     *
319
     * @return string
320
     */
321
    public function getEmail(): string
322
    {
323
        return $this->email;
324
    }
325
326
    /**
327
     * Configure debugger administrator email
328
     *
329
     * @param string $email
330
     * @return $this
331
     */
332
    public function setEmail($email)
333
    {
334
        $this->email = (string) $email;
335
        return $this;
336
    }
337
338
    /**
339
     * @return int
340
     */
341
    public function getMaxDepth(): int
342
    {
343
        return $this->maxDepth;
344
    }
345
346
    /**
347
     * Variable dump max depth
348
     *
349
     * @param int $maxDepth
350
     * @return $this
351
     */
352
    public function setMaxDepth($maxDepth)
353
    {
354
        $this->maxDepth = (int) $maxDepth;
355
        return $this;
356
    }
357
358
    /**
359
     * @return int
360
     */
361
    public function getMaxLength(): int
362
    {
363
        return $this->maxLength;
364
    }
365
366
    /**
367
     * Maximum length of a variable
368
     *
369
     * @param int $maxLength
370
     * @return $this
371
     */
372
    public function setMaxLength($maxLength)
373
    {
374
        $this->maxLength = (int) $maxLength;
375
        return $this;
376
    }
377
378
    /**
379
     * Return debugger bar title
380
     *
381
     * @return string
382
     */
383
    public function getBarTitle(): string
384
    {
385
        return $this->barTitle;
386
    }
387
388
    /**
389
     * Set debugger bar custom title
390
     *
391
     * @param string $barTitle
392
     * @return $this
393
     */
394
    public function setBarTitle($barTitle)
395
    {
396
        $this->barTitle = (string) $barTitle;
397
        return $this;
398
    }
399
400
    /**
401
     * Has debugger bar a disabled logo?
402
     *
403
     * @return bool
404
     */
405
    public function hasBarNoLogo(): bool
406
    {
407
        return $this->barNoLogo;
408
    }
409
410
    /**
411
     * Set debugger bar logo disabled
412
     *
413
     * @param bool $barNoLogo
414
     * @return $this
415
     */
416
    public function setBarNoLogo($barNoLogo = true)
417
    {
418
        $this->barNoLogo = (bool) $barNoLogo;
419
        return $this;
420
    }
421
422
    /**
423
     * Has debugger bar close button disabled?
424
     *
425
     * @return bool
426
     */
427
    public function hasBarNoClose(): bool
428
    {
429
        return $this->barNoClose;
430
    }
431
432
    /**
433
     * Disable debugger bar close button
434
     *
435
     * @param bool $barNoClose
436
     * @return $this
437
     */
438
    public function setBarNoClose($barNoClose = true)
439
    {
440
        $this->barNoClose = (bool) $barNoClose;
441
        return $this;
442
    }
443
444
    /**
445
     * Is fire logger enabled?
446
     *
447
     * @return bool
448
     */
449
    public function hasFireLogger(): bool
450
    {
451
        return $this->fireLogger;
452
    }
453
454
    /**
455
     * Use fire logger
456
     *
457
     * @param bool $fireLogger
458
     * @return $this
459
     */
460
    public function setFireLogger($fireLogger = true)
461
    {
462
        $this->fireLogger = (bool) $fireLogger;
463
        return $this;
464
    }
465
}
466