DebuggerOptions   A
last analyzed

Complexity

Total Complexity 21

Size/Duplication

Total Lines 247
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 247
rs 10
c 0
b 0
f 0
wmc 21
lcom 3
cbo 1

19 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 4 1
A isDisabled() 0 4 1
A getMode() 0 4 1
A hasBar() 0 4 1
A isStrict() 0 4 1
A getLog() 0 7 2
A getEmail() 0 4 1
A getMaxDepth() 0 4 1
A getMaxLen() 0 4 1
A setEnabled() 0 5 1
A setMode() 0 5 2
A setBar() 0 5 1
A setStrict() 0 5 1
A setLog() 0 5 1
A setEmail() 0 5 1
A setMaxDepth() 0 5 1
A setMaxLen() 0 5 1
A setDevMode() 0 5 1
A setPubMode() 0 5 1
1
<?php
2
/**
3
 * Webino™ (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino for the canonical source repository
6
 * @copyright   Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoAppLib\Options;
12
13
use Tracy\Debugger as Tracy;
14
use Zend\Stdlib\AbstractOptions;
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 bool
38
     */
39
    protected $strict = true;
40
41
    /**
42
     * @var string|null
43
     */
44
    protected $log;
45
46
    /**
47
     * @var string
48
     */
49
    protected $email = '';
50
51
    /**
52
     * @var int
53
     */
54
    protected $maxDepth = 10;
55
56
    /**
57
     * @var int
58
     */
59
    protected $maxLen = 300;
60
61
    /**
62
     * Is debugger enabled?
63
     *
64
     * @return bool
65
     */
66
    public function isEnabled()
67
    {
68
        return $this->enabled;
69
    }
70
71
    /**
72
     * Is debugger disabled?
73
     *
74
     * @return bool
75
     */
76
    public function isDisabled()
77
    {
78
        return !$this->enabled;
79
    }
80
81
    /**
82
     * Debugger mode
83
     *
84
     * true  = production|false
85
     * false = development|null
86
     * null  = autodetect|IP address(es) csv/array
87
     *
88
     * @return bool|null
89
     */
90
    public function getMode()
91
    {
92
        return $this->mode;
93
    }
94
95
    /**
96
     * Is debugger bar enabled?
97
     *
98
     * @return bool
99
     */
100
    public function hasBar()
101
    {
102
        return $this->bar;
103
    }
104
105
    /**
106
     * @return bool
107
     */
108
    public function isStrict()
109
    {
110
        return $this->strict;
111
    }
112
113
    /**
114
     * @return string Empty string to disable, null for default
115
     */
116
    public function getLog()
117
    {
118
        if (null === $this->log) {
119
            $this->setLog('.');
120
        }
121
        return $this->log;
122
    }
123
124
    /**
125
     * Administrator address
126
     *
127
     * @return string
128
     */
129
    public function getEmail()
130
    {
131
        return $this->email;
132
    }
133
134
    /**
135
     * @return int
136
     */
137
    public function getMaxDepth()
138
    {
139
        return $this->maxDepth;
140
    }
141
142
    /**
143
     * @return int
144
     */
145
    public function getMaxLen()
146
    {
147
        return $this->maxLen;
148
    }
149
150
    /**
151
     * Enable debugger
152
     *
153
     * @param bool $enabled
154
     * @return $this
155
     */
156
    public function setEnabled($enabled)
157
    {
158
        $this->enabled = (bool) $enabled;
159
        return $this;
160
    }
161
162
    /**
163
     * Debugger mode, production or development.
164
     *
165
     * @param bool|null $mode
166
     * @return $this
167
     */
168
    public function setMode($mode)
169
    {
170
        $this->mode = (null === $mode ? null : (bool) $mode);
171
        return $this;
172
    }
173
174
    /**
175
     * Force development mode
176
     *
177
     * @return $this
178
     */
179
    public function setDevMode()
180
    {
181
        $this->setMode(Tracy::DEVELOPMENT);
182
        return $this;
183
    }
184
185
    /**
186
     * Force production mode
187
     *
188
     * @return $this
189
     */
190
    public function setPubMode()
191
    {
192
        $this->setMode(Tracy::PRODUCTION);
193
        return $this;
194
    }
195
196
    /**
197
     * @param bool|true $bar
198
     * @return $this
199
     */
200
    public function setBar($bar = true)
201
    {
202
        $this->bar = (bool) $bar;
203
        return $this;
204
    }
205
206
    /**
207
     * Strict errors?
208
     *
209
     * @param bool|true $strict
210
     * @return $this
211
     */
212
    public function setStrict($strict = true)
213
    {
214
        $this->strict = (bool) $strict;
215
        return $this;
216
    }
217
218
    /**
219
     * Path to log directory
220
     *
221
     * @param string $log
222
     * @return $this
223
     */
224
    public function setLog($log)
225
    {
226
        $this->log = realpath($log);
227
        return $this;
228
    }
229
230
    /**
231
     * Configure debugger administrator email
232
     *
233
     * @param string $email
234
     * @return $this
235
     */
236
    public function setEmail($email)
237
    {
238
        $this->email = (string) $email;
239
        return $this;
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
     * Maximum length of a variable
256
     *
257
     * @param int $maxLen
258
     * @return $this
259
     */
260
    public function setMaxLen($maxLen)
261
    {
262
        $this->maxLen = (int) $maxLen;
263
        return $this;
264
    }
265
}
266