DefaultConfigs::get()   B
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 473
Code Lines 344

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 344
nc 1
nop 0
dl 0
loc 473
rs 8.2857
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Htsl\Helper;
4
5
////////////////////////////////////////////////////////////////
6
7
class DefaultConfigs
8
{
9
	/**
10
	 * Getting default configurations of HTSL and Htsl.php
11
	 *
12
	 * @access public
13
	 *
14
	 * @return array
15
	 */
16
	public static function get():array
17
	{
18
		return [
19
			'debug'=> false,
20
			'charset'=> 'UTF-8',
21
			'doc_types'=> [
22
				'HTML5'=>  '<!DOCTYPE html>',
23
				'XML1'=>   '<?xml version="1.0" encoding="%s"?>',
24
				'SVG1.1'=> "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">",
25
			],
26
			'ENT_flags'=> [
27
				'HTML5'=>  ENT_HTML5,
28
				'XML1'=>   ENT_XML1,
29
				'SVG1.1'=> ENT_XML1,
30
				'XHTML'=>  ENT_XHTML,
31
				'HTML4'=>  ENT_HTML401,
32
			],
33
			'control_nodes'=> [
34
				''=> [
35
					'opener'=> '<?php %s?>',
36
				],
37
				'for'=> [
38
					'opener'=> '<?php $$_FLAG_$=false; for( %s/[^;]*$|;$|;[^ ]/\_/ ): $$_FLAG_$=true;?>',
39
					'close_by'=> [
40
						'/else|then/'=> '<?php endfor; if( $$_FLAG_$ ):?>',
41
					],
42
					'closer'=> '<?php endfor;?>',
43
				],
44
				'while'=> [
45
					'opener'=> '<?php $$_FLAG_$=false; while( %s ): $$_FLAG_$=true;?>',
46
					'close_by'=> [
47
						'/else|then/'=> '<?php endwhile; if( $$_FLAG_$ ):?>',
48
					],
49
					'closer'=> '<?php endwhile;?>',
50
				],
51
				'do-while'=> [
52
					'opener'=> '<?php $$_FLAG_$=0; do{ ++$$_FLAG_$;?>',
53
					'closer'=> '<?php }while( %s );?>',
54
					'close_by'=> [
55
						'/else|then/'=> '<?php }while( %s ); if( $$_FLAG_$>1 ):?>',
56
					],
57
					'closer'=> '<?php }while( %s );?>',
58
				],
59
				'for-each'=> [
60
					'opener'=> '<?php $$_FLAG_$=false; foreach( %s/ as/??[] as/ ): $$_FLAG_$=true;?>',
61
					'close_by'=> [
62
						'/else|then/'=> '<?php endforeach; if( $$_FLAG_$ ):?>',
63
					],
64
					'closer'=> '<?php endforeach;?>',
65
				],
66
				'continue'=> [
67
					'multiple'=> [
68
						[
69
							'pattern'=> '/\)$/',
70
							'opener'=> '<?php if( %s ) continue;?>',
71
							'closer'=> '',
72
						],
73
						[
74
							'pattern'=> '/\\w$/',
75
							'opener'=> '<?php continue;?>',
76
							'closer'=> '',
77
						],
78
					],
79
				],
80
				'break'=> [
81
					'multiple'=> [
82
						[
83
							'pattern'=> '/\)$/',
84
							'opener'=> '<?php if( %s ) break;?>',
85
							'closer'=> '',
86
						],
87
						[
88
							'pattern'=> '/\\w$/',
89
							'opener'=> '<?php break;?>',
90
							'closer'=> '',
91
						],
92
					],
93
				],
94
				'if'=> [
95
					'opener'=> '<?php if( %s ):?>',
96
					'close_by'=> [
97
						'/else|then/'=> '',
98
					],
99
					'closer'=> '<?php endif;?>',
100
				],
101
				'if-not'=> [
102
					'opener'=> '<?php if(!( %s )):?>',
103
					'close_by'=> [
104
						'/else|then/'=> '',
105
					],
106
					'closer'=> '<?php endif;?>',
107
				],
108
				'if-all'=> [
109
					'opener'=> '<?php if( %s/[^;]*$/\_//^/( //; / )and( //;$/ )/ ):?>',
110
					'close_by'=> [
111
						'/else|then/'=> '<?php endif; if( %s/[^;]*$/\_//^/( //; / )or( //;$/ )/ ):?>',
112
					],
113
					'closer'=> '<?php endif;?>',
114
				],
115
				'if-all-not'=> [
116
					'opener'=> '<?php if( %s/[^;]*$/\_//^/!( //; / )and!( //;$/ )/ ):?>',
117
					'close_by'=> [
118
						'/else|then/'=> '<?php endif; if( %s/[^;]*$/\_//^/!( //; / )or!( //;$/ )/ ):?>',
119
					],
120
					'closer'=> '<?php endif;?>',
121
				],
122
				'if-not-all-not'=> [
123
					'opener'=> '<?php if( %s/[^;]*$/\_//^/( //; / )or( //;$/ )/ ):?>',
124
					'close_by'=> [
125
						'/else|then/'=> '<?php endif; if( %s/[^;]*$/\_//^/( //; / )and( //;$/ )/ ):?>',
126
					],
127
					'closer'=> '<?php endif;?>',
128
				],
129
				'if-not-all'=> [
130
					'opener'=> '<?php if( %s/[^;]*$/\_//^/!( //; / )or!( //;$/ )/ ):?>',
131
					'close_by'=> [
132
						'/else|then/'=> '<?php endif; if( %s/[^;]*$/\_//^/!( //; / )and!( //;$/ )/ ):?>',
133
					],
134
					'closer'=> '<?php endif;?>',
135
				],
136
				'else-if'=> [
137
					'opener'=> '<?php elseif( %s ):?>',
138
					'close_by'=> [
139
						'/else|then/'=> '',
140
					],
141
					'closer'=> '<?php endif;?>',
142
				],
143
				'else-if-not'=> [
144
					'opener'=> '<?php elseif(!( %s )):?>',
145
					'close_by'=> [
146
						'/else|then/'=> '',
147
					],
148
					'closer'=> '<?php endif;?>',
149
				],
150
				'else'=> [
151
					'opener'=> '<?php else:?>',
152
					'closer'=> '<?php endif;?>',
153
				],
154
				'then'=> [
155
					'opener'=> '',
156
					'close_by'=> [
157
						'/else|then/'=> '',
158
					],
159
					'closer'=> '<?php endif;?>',
160
				],
161
				'switch'=> [
162
					'opener'=> '<?php switch( %s ):?>',
163
					'closer'=> '<?php endswitch;?>',
164
					'scope'=> 'switch',
165
				],
166
				'default'=> [
167
					'in'=> [
168
						'switch'=> [
169
							'opener'=> '<?php default:?>',
170
							'closer'=> '<?php break;?>',
171
							'scope'=> 'root-default',
172
						],
173
						'root-case'=> [
174
							'opener'=> '<?php default:?>',
175
							'closer'=> '',
176
							'scope'=> 'default-in-case',
177
						],
178
					],
179
				],
180
				'case'=> [
181
					'in'=> [
182
						'switch'=> [
183
							'opener'=> '<?php case %s:?>',
184
							'closer'=> '<?php break;?>',
185
							'scope'=> 'root-case',
186
						],
187
						'root-case'=> [
188
							'opener'=> '<?php case %s:?>',
189
							'closer'=> '',
190
							'scope'=> 'case-in-case',
191
						],
192
						'root-default'=> [
193
							'opener'=> '<?php case %s:?>',
194
							'closer'=> '',
195
							'scope'=> 'case-in-case',
196
						],
197
					],
198
				],
199
			],
200
			'tag_nodes'=> [
201
				'SVG1.1'=> $svgTags= [
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces

This check looks for improperly formatted assignments.

Every assignment must have exactly one space before and one space after the equals operator.

To illustrate:

$a = "a";
$ab = "ab";
$abc = "abc";

will have no issues, while

$a   = "a";
$ab  = "ab";
$abc = "abc";

will report issues in lines 1 and 2.

Loading history...
202
					'svg'=> [
203
						'out'=> [
204
							'default_attributes'=> ['xmlns'=> 'http://www.w3.org/2000/svg','version'=> '1.1',],
205
							'params'=> ['viewBox',],
206
							'scope'=> 'svg',
207
						],
208
						'in'=> [
209
							'svg'=> [
210
								'params'=> ['x','y','width','height',],
211
							],
212
						],
213
					],
214
					'*'=> [],
215
					'polygon'=> [
216
						'params'=> ['points',],
217
						'only_in'=> ['svg',],
218
					],
219
					'polyline'=> [
220
						'params'=> ['points',],
221
						'only_in'=> ['svg',],
222
					],
223
					'path'=> [
224
						'params'=> ['d',],
225
						'only_in'=> ['svg',],
226
					],
227
					'line'=> [
228
						'params'=> ['x1','y1','x2','y2',],
229
						'only_in'=> ['svg',],
230
					],
231
					'rect'=> [
232
						'params'=> ['x','y','width','height',],
233
						'only_in'=> ['svg',],
234
					],
235
					'circle'=> [
236
						'params'=> ['cx','cy','r',],
237
						'only_in'=> ['svg',],
238
					],
239
					'ellipse'=> [
240
						'params'=> ['cx','cy','rx','ry',],
241
						'only_in'=> ['svg',],
242
					],
243
					'text'=> [
244
						'params'=> ['x','y',],
245
						'only_in'=> ['svg',],
246
					],
247
				],
248
				'HTML5'=> [
249
					'*'=> [],
250
					''=> [
251
						'opener'=> '&nbsp;',
252
						'closer'=> '',
253
					],
254
					'charset'=> [
255
						'name'=> 'meta',
256
						'params'=> ['charset',],
257
					],
258
					'equiv'=> [
259
						'name'=> 'meta',
260
						'name_value'=> ['http-equiv','content','scheme',],
261
					],
262
					'meta'=> [
263
						'name'=> 'meta',
264
						'name_value'=> ['name','content','scheme',],
265
					],
266
					'php'=> [
267
						'opener'=> '<?php ',
268
						'closer'=> '?>',
269
						'embedding'=> 'php',
270
					],
271
					'code'=> [
272
						'name'=> 'code',
273
						'multiple'=> [
274
							[
275
								'pattern'=> '/\{>$/',
276
								'params'=> ['type',],
277
								'default_attributes'=> ['codeset'=> 'codeset',],
278
								'embedding'=> 'code',
279
							],
280
							[
281
								'pattern'=> '/.?/',
282
								'name'=> 'code',
283
								'params'=> ['type',],
284
							],
285
						],
286
					],
287
					'js'=> [
288
						'multiple'=> [
289
							[
290
								'pattern'=> '/^-js @/',
291
								'name'=> 'script',
292
								'default_attributes'=> ['type'=> 'text/javascript',],
293
								'link'=> 'src',
294
							],
295
							[
296
								'pattern'=> '/^-js\{>/',
297
								'name'=> 'script',
298
								'default_attributes'=> ['type'=> 'text/javascript',],
299
								'embedding'=> 'js',
300
							],
301
						],
302
					],
303
					'css'=> [
304
						'multiple'=> [
305
							[
306
								'pattern'=> '/^-css @/',
307
								'name'=> 'link',
308
								'default_attributes'=> ['rel'=> 'stylesheet','type'=> 'text/css',],
309
								'link'=> 'href',
310
							],
311
							[
312
								'pattern'=> '/^-css\{>/',
313
								'name'=> 'style',
314
								'default_attributes'=> ['type'=> 'text/css',],
315
								'embedding'=> 'css',
316
							],
317
						],
318
					],
319
					'icon'=> [
320
						'name'=> 'link',
321
						'default_attributes'=> ['rel'=> 'icon',],
322
						'params'=> ['sizes',],
323
						'link'=> 'href',
324
					],
325
					'shortcut'=> [
326
						'name'=> 'link',
327
						'default_attributes'=> ['rel'=> 'shortcut icon','type'=> 'image/x-icon',],
328
						'link'=> 'href',
329
					],
330
					'link'=> [
331
						'params'=> ['rel',],
332
						'link'=> 'href',
333
					],
334
					'script'=> [
335
						'params'=> ['type',],
336
						'link'=> 'source',
337
					],
338
					'a'=> [
339
						'link'=> 'href',
340
						'name_value'=> ['name',],
341
						'target'=> 'target',
342
					],
343
					'iframe'=> [
344
						'link'=> 'src',
345
						'default_attributes'=> ['frameborder'=> '0',],
346
						'name_value'=> ['name',],
347
					],
348
					'img'=> [
349
						'link'=> 'src',
350
						'alt'=> 'alt',
351
					],
352
					'fpost'=>   ['name'=> 'form', 'link'=> 'action', 'target'=> 'target', 'name_value'=> ['name',], 'default_attributes'=> ['method'=> 'post',],],
353
					'fupload'=> ['name'=> 'form', 'link'=> 'action', 'target'=> 'target', 'name_value'=> ['name',], 'default_attributes'=> ['method'=> 'post','enctype'=> 'multipart/form-data',],],
354
					'fget'=>    ['name'=> 'form', 'link'=> 'action', 'target'=> 'target', 'name_value'=> ['name',], 'default_attributes'=> ['method'=> 'get',],],
355
					'fput'=>    ['name'=> 'form', 'link'=> 'action', 'target'=> 'target', 'name_value'=> ['name',], 'default_attributes'=> ['method'=> 'put',],],
356
					'fpatch'=>  ['name'=> 'form', 'link'=> 'action', 'target'=> 'target', 'name_value'=> ['name',], 'default_attributes'=> ['method'=> 'patch',],],
357
					'fdelete'=> ['name'=> 'form', 'link'=> 'action', 'target'=> 'target', 'name_value'=> ['name',], 'default_attributes'=> ['method'=> 'delete',],],
358
359
					'fhidden'=>         ['name'=> 'input',  'default_attributes'=> ['type'=> 'hidden',],         'name_value'=> ['name', 'value', 'form',],],
360
					'ftext'=>           ['name'=> 'input',  'default_attributes'=> ['type'=> 'text',],           'name_value'=> ['name', 'value', 'form',], 'alt'=> 'placeholder',],
361
					'fsearch'=>         ['name'=> 'input',  'default_attributes'=> ['type'=> 'search',],         'name_value'=> ['name', 'value', 'form',], 'alt'=> 'placeholder',],
362
					'fpassword'=>       ['name'=> 'input',  'default_attributes'=> ['type'=> 'password',],       'name_value'=> ['name', 'value', 'form',], 'alt'=> 'placeholder',],
363
					'femail'=>          ['name'=> 'input',  'default_attributes'=> ['type'=> 'email',],          'name_value'=> ['name', 'value', 'form',], 'alt'=> 'placeholder',],
364
					'furl'=>            ['name'=> 'input',  'default_attributes'=> ['type'=> 'url',],            'name_value'=> ['name', 'value', 'form',], 'alt'=> 'placeholder',],
365
					'ftel'=>            ['name'=> 'input',  'default_attributes'=> ['type'=> 'tel',],            'name_value'=> ['name', 'value', 'form',], 'alt'=> 'placeholder',],
366
					'fnumber'=>         ['name'=> 'input',  'default_attributes'=> ['type'=> 'number',],         'name_value'=> ['name', 'value', 'form',], 'alt'=> 'placeholder', 'params'=> ['min', 'step', 'max',],],
367
					'frange'=>          ['name'=> 'input',  'default_attributes'=> ['type'=> 'range',],          'name_value'=> ['name', 'value', 'form',],                'params'=> ['min', 'step', 'max',],],
368
					'fradio'=>          ['name'=> 'input',  'default_attributes'=> ['type'=> 'radio',],          'name_value'=> ['name', 'value', 'form',],],
369
					'fcheckbox'=>       ['name'=> 'input',  'default_attributes'=> ['type'=> 'checkbox',],       'name_value'=> ['name', 'value', 'form',],],
370
					'fdate'=>           ['name'=> 'input',  'default_attributes'=> ['type'=> 'date',],           'name_value'=> ['name', 'value', 'form',],],
371
					'fmonth'=>          ['name'=> 'input',  'default_attributes'=> ['type'=> 'month',],          'name_value'=> ['name', 'value', 'form',],],
372
					'fweek'=>           ['name'=> 'input',  'default_attributes'=> ['type'=> 'week',],           'name_value'=> ['name', 'value', 'form',],],
373
					'ftime'=>           ['name'=> 'input',  'default_attributes'=> ['type'=> 'time',],           'name_value'=> ['name', 'value', 'form',],],
374
					'fdatetime'=>       ['name'=> 'input',  'default_attributes'=> ['type'=> 'datetime',],       'name_value'=> ['name', 'value', 'form',],],
375
					'fdatetime-local'=> ['name'=> 'input',  'default_attributes'=> ['type'=> 'datetime-local',], 'name_value'=> ['name', 'value', 'form',],],
376
					'fcolor'=>          ['name'=> 'input',  'default_attributes'=> ['type'=> 'color',],          'name_value'=> ['name', 'value', 'form',],],
377
					'ffile'=>           ['name'=> 'input',  'default_attributes'=> ['type'=> 'file',],           'name_value'=> ['name', 'form',], 'params'=> ['accept',],],
378
379
					'fsubmit'=>         ['name'=> 'button', 'default_attributes'=> ['type'=> 'submit',],         'name_value'=> ['name', 'value','form',], 'link'=> 'formaction', 'target'=> 'formtarget',],
380
					'freset'=>          ['name'=> 'button', 'default_attributes'=> ['type'=> 'reset',],          'name_value'=> ['form',],],
381
					'button'=>         ['name'=> 'button', 'default_attributes'=> ['type'=> 'button',],],
382
383
					'ftextarea'=>       ['name'=> 'textarea', 'name_value'=> ['name','value','form',],'alt'=> 'placeholder',],
384
385
					'fselect'=> [
386
						'name'=> 'select',
387
						'name_value'=> ['name', 'value','form',],
388
						'scope'=> 'select',
389
					],
390
					'datalist'=> [
391
						'params'=> ['id',],
392
						'scope'=> 'datalist',
393
					],
394
					'optgroup'=> [
395
						'in'=> [
396
							'select'=> [
397
								'name_value'=> ['label',],
398
							],
399
						],
400
					],
401
					'option'=> [
402
						'in'=> [
403
							'select'=> [
404
								'scope_function'=> function( $scope ){
405
									if( $scope['value']===$this['value'] ){
406
										$this['selected']= 'selected';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces

This check looks for improperly formatted assignments.

Every assignment must have exactly one space before and one space after the equals operator.

To illustrate:

$a = "a";
$ab = "ab";
$abc = "abc";

will have no issues, while

$a   = "a";
$ab  = "ab";
$abc = "abc";

will report issues in lines 1 and 2.

Loading history...
407
									};
408
								},
409
								'name_value'=> ['value',],
410
								'alt'=> 'label',
411
							],
412
							'datalist'=> [
413
								'name_value'=> ['value',],
414
							],
415
						],
416
					],
417
418
					'param'=> [
419
						'name_value'=> ['name','value',],
420
					],
421
					'source'=> [
422
						'params'=>['type',],
423
						'link'=> 'src',
424
					],
425
					'base'=> [
426
						'link'=> 'href',
427
						'target'=> 'target',
428
					],
429
					'map'=> [
430
						'params'=> ['name',],
431
						'scope'=> 'area-map',
432
					],
433
					'area'=> [
434
						'link'=> 'href',
435
						'params'=> ['shape','coords'],
436
						'target'=> 'target',
437
						'only_in'=> ['area-map',],
438
					],
439
					'audio'=> [
440
						'link'=> 'src',
441
					],
442
					'video'=> [
443
						'link'=> 'src',
444
					],
445
					'track'=> [
446
						'link'=> 'src',
447
						'param'=> ['kind',],
448
						'alt'=> 'label',
449
					],
450
					'progress'=> [
451
						'param'=> ['value','max',],
452
					],
453
				]+$svgTags,
454
			],
455
			'empty_tags'=> [
456
				'HTML5'=> [
457
					'br'=>       true,
458
					'hr'=>       true,
459
					'img'=>      true,
460
					'input'=>    true,
461
					'link'=>     true,
462
					'meta'=>     true,
463
					'option'=>   true,
464
					'param'=>    true,
465
					'source'=>   true,
466
					'base'=>     true,
467
					'area'=>     true,
468
					'progress'=> true,
469
				],
470
				'SVG1.1'=> [
471
					'polygon'=>  true,
472
					'polyline'=> true,
473
					'path'=>     true,
474
					'line'=>     true,
475
					'rect'=>     true,
476
					'circle'=>   true,
477
					'ellipse'=>  true,
478
				],
479
			],
480
			'indentation'=> [
481
				'HTML5'=>  false,
482
				'HTML4'=>  false,
483
				'XHTML'=>  false,
484
				'XML1'=>   "\t",
485
				'SVG1.1'=> "\t",
486
			],
487
		];
488
	}
489
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
490