Passed
Push — master ( 58b65e...aa71b5 )
by WEBEWEB
04:28
created

SyntaxHighlighterDefaults::setTabSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the syntaxhighligter-bundle package.
5
 *
6
 * (c) 2017 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\SyntaxHighlighterBundle\API;
13
14
use WBW\Bundle\SyntaxHighlighterBundle\Encoder\SyntaxHighlighterEncoder;
15
16
/**
17
 * SyntaxHighlighter defaults.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\SyntaxHighlighterBundle\API
21
 * @final
22
 */
23
final class SyntaxHighlighterDefaults {
24
25
    /**
26
     * Auto links.
27
     *
28
     * @var boolean
29
     */
30
    private $autoLinks = true;
31
32
    /**
33
     * Class name.
34
     *
35
     * @var string
36
     */
37
    private $className = "";
38
39
    /**
40
     * Collapse.
41
     *
42
     * @var boolean
43
     */
44
    private $collapse = false;
45
46
    /**
47
     * First line.
48
     *
49
     * @var integer
50
     */
51
    private $firstLine = 1;
52
53
    /**
54
     * Gutter.
55
     *
56
     * @var boolean
57
     */
58
    private $gutter = true;
59
60
    /**
61
     * Highlight.
62
     *
63
     * @var array
64
     */
65
    private $highlight;
66
67
    /**
68
     * HTML script.
69
     *
70
     * @var boolean
71
     */
72
    private $htmlScript = false;
73
74
    /**
75
     * Samrt tabs.
76
     *
77
     * @var boolean
78
     */
79
    private $smartTabs = true;
80
81
    /**
82
     * Tab size.
83
     *
84
     * @var integer
85
     */
86
    private $tabSize = 4;
87
88
    /**
89
     * Toolbar.
90
     *
91
     * @var boolean
92
     */
93
    private $toolbar = true;
94
95
    /**
96
     * Constructor.
97
     */
98
    public function __construct() {
99
        // NOTHING TO DO.
100
    }
101
102
    /**
103
     * Convert into a string representing this instance.
104
     *
105
     * @return string Returns a string representing this instance.
106
     */
107
    public function __toString() {
108
109
        // Initialize.
110
        $script = "SyntaxHighlighter.defaults";
111
112
        // Initialize the output.
113
        $output = [];
114
115
        SyntaxHighlighterEncoder::booleanToString($this->autoLinks, $output, $script . "['auto-links'] = ", ";");
116
        SyntaxHighlighterEncoder::stringToString($this->className, $output, $script . "['class-name'] = \"", "\";");
117
        SyntaxHighlighterEncoder::booleanToString($this->collapse, $output, $script . "['collapse'] = ", ";");
118
        SyntaxHighlighterEncoder::stringToString($this->firstLine, $output, $script . "['first-line'] = ", ";");
119
        SyntaxHighlighterEncoder::booleanToString($this->gutter, $output, $script . "['gutter'] = ", ";");
120
        SyntaxHighlighterEncoder::arrayToString($this->highlight, $output, $script . "['highlight'] = ", ";");
121
        SyntaxHighlighterEncoder::booleanToString($this->htmlScript, $output, $script . "['html-script'] = ", ";");
122
        SyntaxHighlighterEncoder::booleanToString($this->smartTabs, $output, $script . "['smart-tabs'] = ", ";");
123
        SyntaxHighlighterEncoder::stringToString($this->tabSize, $output, $script . "['tab-size'] = ", ";");
124
        SyntaxHighlighterEncoder::booleanToString($this->toolbar, $output, $script . "['toolbar'] = ", ";");
125
126
        // Return the output.
127
        return implode("\n", $output);
128
    }
129
130
    /**
131
     * Get the auto links.
132
     *
133
     * @return boolean Returns the auto links.
134
     */
135
    public function getAutoLinks() {
136
        return $this->autoLinks;
137
    }
138
139
    /**
140
     * Get the class name.
141
     *
142
     * @return string Returns the class name.
143
     */
144
    public function getClassName() {
145
        return $this->className;
146
    }
147
148
    /**
149
     * Get the collapse.
150
     *
151
     * @return boolean Returns the collapse.
152
     */
153
    public function getCollapse() {
154
        return $this->collapse;
155
    }
156
157
    /**
158
     * Get the first line.
159
     *
160
     * @return integer Returns the first line.
161
     */
162
    public function getFirstLine() {
163
        return $this->firstLine;
164
    }
165
166
    /**
167
     * Get the gutter.
168
     *
169
     * @return boolean Returns the gutter.
170
     */
171
    public function getGutter() {
172
        return $this->gutter;
173
    }
174
175
    /**
176
     * Get the highlight.
177
     *
178
     * @return array Returns the hightlight.
179
     */
180
    public function getHighlight() {
181
        return $this->highlight;
182
    }
183
184
    /**
185
     * Get the HTML script.
186
     *
187
     * @return boolean Returns the HTML script.
188
     */
189
    public function getHtmlScript() {
190
        return $this->htmlScript;
191
    }
192
193
    /**
194
     * Get the smart tabs.
195
     *
196
     * @return boolean Returns the smart tabs.
197
     */
198
    public function getSmartTabs() {
199
        return $this->smartTabs;
200
    }
201
202
    /**
203
     * Get the tab size.
204
     *
205
     * @return integer Returns the tab size.
206
     */
207
    public function getTabSize() {
208
        return $this->tabSize;
209
    }
210
211
    /**
212
     * Get the toolbar.
213
     *
214
     * @return boolean Returns the toolbar.
215
     */
216
    public function getToolbar() {
217
        return $this->toolbar;
218
    }
219
220
    /**
221
     * Set the auto links.
222
     *
223
     * @param boolean $autoLinks The auto links.
224
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
225
     */
226
    public function setAutoLinks($autoLinks = true) {
227
        $this->autoLinks = $autoLinks;
228
        return $this;
229
    }
230
231
    /**
232
     * Set the class name.
233
     *
234
     * @param string $className The class name.
235
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
236
     */
237
    public function setClassName($className = "") {
238
        $this->className = $className;
239
        return $this;
240
    }
241
242
    /**
243
     * Set the collapse.
244
     *
245
     * @param boolean $collapse The collapse.
246
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
247
     */
248
    public function setCollapse($collapse = false) {
249
        $this->collapse = $collapse;
250
        return $this;
251
    }
252
253
    /**
254
     * Set the first line.
255
     *
256
     * @param integer $firstLine The first line.
257
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
258
     */
259
    public function setFirstLine($firstLine = 1) {
260
        $this->firstLine = $firstLine;
261
        return $this;
262
    }
263
264
    /**
265
     * Set the gutter.
266
     *
267
     * @param boolean $gutter The gutter.
268
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
269
     */
270
    public function setGutter($gutter = true) {
271
        $this->gutter = $gutter;
272
        return $this;
273
    }
274
275
    /**
276
     * Set the highlight.
277
     *
278
     * @param array $highlight The highlight.
279
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
280
281
     */
282
    public function setHighlight(array $highlight = null) {
283
        $this->highlight = $highlight;
284
        return $this;
285
    }
286
287
    /**
288
     * Set the HTML script.
289
     *
290
     * @param boolean $htmlScript The HTML script.
291
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
292
293
     */
294
    public function setHtmlScript($htmlScript = false) {
295
        $this->htmlScript = $htmlScript;
296
        return $this;
297
    }
298
299
    /**
300
     * Set the smart tabs.
301
     *
302
     * @param boolean $smartTabs The smart tabs.
303
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
304
     */
305
    public function setSmartTabs($smartTabs = true) {
306
        $this->smartTabs = $smartTabs;
307
        return $this;
308
    }
309
310
    /**
311
     * Set the tab size.
312
     *
313
     * @param integer $tabSize The tab size.
314
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
315
316
     */
317
    public function setTabSize($tabSize = 4) {
318
        $this->tabSize = $tabSize;
319
        return $this;
320
    }
321
322
    /**
323
     * Set the toolbar.
324
     *
325
     * @param boolean $toolbar The toolbar.
326
     * @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults.
327
328
     */
329
    public function setToolbar($toolbar = true) {
330
        $this->toolbar = $toolbar;
331
        return $this;
332
    }
333
334
}
335