Completed
Push — develop ( a50640...00d773 )
by Peter
10:42
created

DebuggerOptions::showBar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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-2017 Webino, s. r. o. (http://webino.sk/)
7
 * @license     BSD-3-Clause
8
 */
9
10
namespace WebinoDebug\Options;
11
12
use WebinoDebug\Debugger\Bar\ConfigPanel;
13
use WebinoDebug\Debugger\Bar\EventPanel;
14
use WebinoDebug\Debugger\Bar\InfoPanel;
15
use Zend\Stdlib\AbstractOptions;
16
17
/**
18
 * Class DebuggerOptions
19
 */
20
class DebuggerOptions extends AbstractOptions
21
{
22
    /**
23
     * @var bool
24
     */
25
    protected $enabled = true;
26
27
    /**
28
     * @var bool|null
29
     */
30
    protected $mode = null;
31
32
    /**
33
     * @var bool
34
     */
35
    protected $bar = false;
36
37
    /**
38
     * @var array
39
     */
40
    protected $barPanels = [
41
        'WebinoDebug:info'   => InfoPanel::class,
42
        'WebinoDebug:config' => ConfigPanel::class,
43
        'WebinoDebug:events' => EventPanel::class,
44
    ];
45
46
    /**
47
     * @var bool
48
     */
49
    protected $strict = true;
50
51
    /**
52
     * @var string|null
53
     */
54
    protected $log;
55
56
    /**
57
     * @var string
58
     */
59
    protected $email = '';
60
61
    /**
62
     * @var int
63
     */
64
    protected $maxDepth = 10;
65
66
    /**
67
     * @var int
68
     */
69
    protected $maxLength = 300;
70
71
    /**
72
     * Is debugger enabled?
73
     *
74
     * @return bool
75
     */
76
    public function isEnabled()
77
    {
78
        return $this->enabled;
79
    }
80
81
    /**
82
     * Enable debugger
83
     *
84
     * @param bool $enabled
85
     * @return $this
86
     */
87
    public function setEnabled($enabled)
88
    {
89
        $this->enabled = (bool) $enabled;
90
        return $this;
91
    }
92
93
    /**
94
     * Is debugger disabled?
95
     *
96
     * @return bool
97
     */
98
    public function isDisabled()
99
    {
100
        return !$this->enabled;
101
    }
102
103
    /**
104
     * Debugger mode
105
     *
106
     * true  = production|false
107
     * false = development|null
108
     * null  = autodetect|IP address(es) csv/array
109
     *
110
     * @return bool|null
111
     */
112
    public function getMode()
113
    {
114
        return $this->mode;
115
    }
116
117
    /**
118
     * Debugger mode, production or development.
119
     *
120
     * @param bool|null $mode
121
     * @return $this
122
     */
123
    public function setMode($mode)
124
    {
125
        $this->mode = (null === $mode ? null : (bool) $mode);
126
        return $this;
127
    }
128
129
    /**
130
     * Is debugger bar enabled?
131
     *
132
     * @return bool
133
     */
134
    public function showBar()
135
    {
136
        return $this->bar;
137
    }
138
139
    /**
140
     * @param bool $bar
141
     * @return $this
142
     */
143
    public function setBar($bar)
144
    {
145
        $this->bar = (bool) $bar;
146
        return $this;
147
    }
148
149
    /**
150
     * Debugger bar panels
151
     *
152
     * @return array
153
     */
154
    public function getBarPanels()
155
    {
156
        return $this->barPanels;
157
    }
158
159
    /**
160
     * @param array $barPanels
161
     * @return $this
162
     */
163
    public function setBarPanels(array $barPanels)
164
    {
165
        $this->barPanels = $barPanels;
166
        return $this;
167
    }
168
169
    /**
170
     * @return bool
171
     */
172
    public function isStrict()
173
    {
174
        return $this->strict;
175
    }
176
177
    /**
178
     * Strict errors?
179
     *
180
     * @param bool $strict
181
     * @return $this
182
     */
183
    public function setStrict($strict)
184
    {
185
        $this->strict = (bool) $strict;
186
        return $this;
187
    }
188
189
    /**
190
     * @return string Empty string to disable, null for default
191
     */
192
    public function getLog()
193
    {
194
        if (null === $this->log) {
195
            $this->setLog('data/log');
196
        }
197
        return $this->log;
198
    }
199
200
    /**
201
     * Path to log directory
202
     *
203
     * @param string $log
204
     * @return $this
205
     */
206
    public function setLog($log)
207
    {
208
        $this->log = realpath($log);
209
        return $this;
210
    }
211
212
    /**
213
     * Administrator address
214
     *
215
     * @return string
216
     */
217
    public function getEmail()
218
    {
219
        return $this->email;
220
    }
221
222
    /**
223
     * Configure debugger administrator email
224
     *
225
     * @param string $email
226
     * @return $this
227
     */
228
    public function setEmail($email)
229
    {
230
        $this->email = (string) $email;
231
        return $this;
232
    }
233
234
    /**
235
     * @return int
236
     */
237
    public function getMaxDepth()
238
    {
239
        return $this->maxDepth;
240
    }
241
242
    /**
243
     * Variable dump max depth
244
     *
245
     * @param int $maxDepth
246
     * @return $this
247
     */
248
    public function setMaxDepth($maxDepth)
249
    {
250
        $this->maxDepth = (int) $maxDepth;
251
        return $this;
252
    }
253
254
    /**
255
     * @return int
256
     */
257
    public function getMaxLength()
258
    {
259
        return $this->maxLength;
260
    }
261
262
    /**
263
     * Maximum length of a variable
264
     *
265
     * @param int $maxLength
266
     * @return $this
267
     */
268
    public function setMaxLength($maxLength)
269
    {
270
        $this->maxLength = (int) $maxLength;
271
        return $this;
272
    }
273
}
274