CreatePhpCode::getPhpCodeWhile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 5
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Tdmcreate\Files;
4
5
use XoopsModules\Tdmcreate;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 */
16
/**
17
 * tdmcreate module.
18
 *
19
 * @copyright       XOOPS Project (https://xoops.org)
20
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
21
 *
22
 * @since           2.5.0
23
 *
24
 * @author          Txmod Xoops http://www.txmodxoops.org
25
 *
26
 */
27
28
/**
29
 * Class CreatePhpCode.
30
 */
31
class CreatePhpCode
32
{
33
    /**
34
     * @static function getInstance
35
     * @param null
36
     * @return CreatePhpCode
37
     */
38
    public static function getInstance()
39
    {
40
        static $instance = false;
41
        if (!$instance) {
42
            $instance = new self();
43
        }
44
45
        return $instance;
46
    }
47
48
    /**
49
     * @public function getPhpCodeCommentLine
50
     * @param        $comment
51
     * @param        $var
52
     * @param string $t
53
     * @param string $n
54
     * @return string
55
     */
56
    public function getPhpCodeCommentLine($comment = null, $var = null, $t = '', $n = "\n")
57
    {
58
        $value = !empty($var) ? ' ' . $var : '';
59
        $ret   = "{$t}// {$comment}{$value}{$n}";
60
61
        return $ret;
62
    }
63
64
    /**
65
     * @public function getPhpCodeCommentMultiLine
66
     * @param array  $multiLine
67
     *
68
     * @param string $t
69
     * @return string
70
     */
71
    public function getPhpCodeCommentMultiLine($multiLine = [], $t = '')
72
    {
73
        $values = !empty($multiLine) ? $multiLine : [];
74
        $ret    = "\n{$t}/**\n";
75
        foreach ($values as $string => $value) {
76
            if ('' === $string && '' === $value) {
77
                $ret .= "{$t} *\n";
78
            } else {
79
                $ret .= "{$t} * {$string} {$value}\n";
80
            }
81
        }
82
        $ret .= "{$t} */\n";
83
84
        return $ret;
85
    }
86
87
    /**
88
     * @public function getPhpCodeDefine
89
     * @param $left
90
     * @param $right
91
     *
92
     * @param string $t
93
     * @param bool $leftstr
94
     * @return string
95
     */
96
    public function getPhpCodeDefine($left, $right, $t = '', $leftstr = true)
97
    {
98
        $ret = "{$t}define(";
99
        if ($leftstr) {
100
            $ret .= "'{$left}'";
101
        } else {
102
            $ret .= "{$left}";
103
        }
104
        $ret .= ", {$right});\n";
105
        return $ret;
106
    }
107
108
    /**
109
     * @public function getPhpCodeDefine
110
     * @param $left
111
     * @param $right
112
     *
113
     * @return string
114
     */
115
    public function getPhpCodeDefined($left = 'XOOPS_ROOT_PATH', $right = 'Restricted access')
116
    {
117
        return "defined('{$left}') || die('{$right}');\n";
118
    }
119
120
    /**
121
     * @public function getPhpCodeGlobals
122
     * @param $var
123
     * @param $value
124
     *
125
     * @return string
126
     */
127
    public function getPhpCodeGlobals($var, $value = '')
128
    {
129
        if ('' != $value) {
130
            $ret = "\$GLOBALS['{$var}'] = \${$value};\n";
131
        } else {
132
            $ret = "\$GLOBALS['{$var}']";
133
        }
134
135
        return $ret;
136
    }
137
138
    /**
139
     * @public function getPhpCodeGlobalsVariables
140
     * @param $var
141
     * @param $type
142
     *
143
     * @return string
144
     */
145
    public function getPhpCodeGlobalsVariables($var = null, $type = 'REQUEST')
146
    {
147
        $type = mb_strtoupper($type);
148
        switch ($type) {
149
            case 'GET':
150
                $ret = "\$_GET['{$var}']";
151
                break;
152
            case 'POST':
153
                $ret = "\$_POST['{$var}']";
154
                break;
155
            case 'FILES':
156
                $ret = "\$_FILES['{$var}']";
157
                break;
158
            case 'COOKIE':
159
                $ret = "\$_COOKIE['{$var}']";
160
                break;
161
            case 'ENV':
162
                $ret = "\$_ENV['{$var}']";
163
                break;
164
            case 'SERVER':
165
                $ret = "\$_SERVER['{$var}']";
166
                break;
167
            default:
168
                $ret = "\$_REQUEST['{$var}']";
169
                break;
170
        }
171
172
        return $ret;
173
    }
174
175
    /**
176
     * @public function getPhpCodeRemoveCarriageReturn
177
     * @param        $string
178
     *
179
     * @param string $n
180
     * @param string $t
181
     * @return string
182
     */
183
    public function getPhpCodeRemoveCarriageReturn($string, $n = "\n", $t = "\r")
184
    {
185
        return str_replace([(string)$n, (string)$t], '', $string);
186
    }
187
188
    /**
189
     * @public function getPhpCodeFileExists
190
     * @param $filename
191
     *
192
     * @return string
193
     */
194
    public function getPhpCodeFileExists($filename)
195
    {
196
        return "file_exists({$filename})";
197
    }
198
199
    /**
200
     * @public function getPhpCodeIncludeDir
201
     * @param        $directory
202
     * @param        $filename
203
     * @param bool   $once
204
     * @param bool   $isPath
205
     *
206
     * @param string $type
207
     * @param string $t
208
     * @return string
209
     */
210
    public function getPhpCodeIncludeDir($directory = null, $filename = null, $once = false, $isPath = false, $type = 'include', $t = '')
211
    {
212
        if ('' === $type) {
213
            $type = 'include';
214
        }
215
        if (false === $once) {
216
            if (!$isPath) {
217
                $ret = "{$t}{$type} {$directory} . '/{$filename}.php';\n";
218
            } else {
219
                $ret = "{$t}{$type} {$directory};\n";
220
            }
221
        } else {
222
            if (!$isPath) {
223
                $ret = "{$t}{$type}_once {$directory} . '/{$filename}.php';\n";
224
            } else {
225
                $ret = "{$t}{$type}_once {$directory};\n";
226
            }
227
        }
228
229
        return $ret;
230
    }
231
232
    /**
233
     * @public function getPhpCodeTernaryOperator
234
     * @param $return
235
     * @param $condition
236
     * @param $one
237
     * @param $two
238
     * @param $t - Indentation
0 ignored issues
show
Documentation Bug introduced by
The doc comment - at position 0 could not be parsed: Unknown type name '-' at position 0 in -.
Loading history...
239
     *
240
     * @return string
241
     */
242
    public function getPhpCodeTernaryOperator($return, $condition, $one, $two, $t = '')
243
    {
244
        return "{$t}\${$return} = {$condition} ? {$one} : {$two};\n";
245
    }
246
247
    /**
248
     * @public function getPhpCodeClass
249
     * @param $name
250
     * @param $content
251
     * @param $extends
252
     * @param $type
253
     *
254
     * @return string
255
     */
256
    public function getPhpCodeClass($name = null, $content = null, $extends = null, $type = null)
257
    {
258
        $typ = (null != $type) ? "{$type} " : '';
259
        $ext = (null != $extends) ? " extends {$extends}" : '';
260
        $ret = "{$typ}class {$name}{$ext}\n";
261
        $ret .= '{';
262
        $ret .= $content;
263
        $ret .= "}\n";
264
265
        return $ret;
266
    }
267
268
    /**
269
     * @public function getPhpCodeClass
270
     * @param $type
271
     * @param $name
272
     * @param $assign
273
     * @param $t - Indentation
0 ignored issues
show
Documentation Bug introduced by
The doc comment - at position 0 could not be parsed: Unknown type name '-' at position 0 in -.
Loading history...
274
     *
275
     * @return string
276
     */
277
    public function getPhpCodeVariableClass($type = 'private', $name = null, $assign = 'null', $t = '')
278
    {
279
        return "{$t}{$type} \${$name} = {$assign};\n";
280
    }
281
282
    /**
283
     * @public function getPhpCodeInstance
284
     * @param $name
285
     * @param $content
286
     * @param $extends
287
     * @param $type
288
     *
289
     * @return string
290
     */
291
    public function getPhpCodeInterface($name = null, $content = null, $extends = null, $type = null)
292
    {
293
        $typ = (null != $type) ? "{$type} " : '';
294
        $ext = (null != $extends) ? " extends {$extends}" : '';
295
        $ret = "{$typ}interface {$name}{$ext}\n";
296
        $ret .= '{';
297
        $ret .= $content;
298
        $ret .= "}\n";
299
300
        return $ret;
301
    }
302
303
    /**
304
     * @public function getPhpCodeFunction
305
     * @param        $name
306
     * @param        $params
307
     * @param        $content
308
     * @param        $method
309
     * @param bool   $isRef
310
     * @param string $t - Indentation
311
     * @return string
312
     */
313
    public function getPhpCodeFunction($name = null, $params = null, $content = null, $method = null, $isRef = false, $t = '')
314
    {
315
        $inClass = (null != $method) ? $method : '';
316
        $ref     = (false !== $isRef) ? '&' : '';
317
        $ret     = "{$t}{$inClass}function {$ref}{$name}({$params})\n";
318
        $ret     .= "{$t}{\n";
319
        $ret     .= $content;
320
        $ret     .= "{$t}}\n";
321
322
        return $ret;
323
    }
324
325
    /**
326
     * @public function getPhpCodeConditions
327
     * @param string $condition
328
     * @param string $operator
329
     * @param string $type
330
     * @param string $contentIf
331
     * @param mixed $contentElse
332
     * @param string $t - Indentation
333
     *
334
     * @param string $conditionElse
335
     * @return string
336
     */
337
    public function getPhpCodeConditions($condition = null, $operator = null, $type = null, $contentIf = null, $contentElse = false, $t = '', $conditionElse = '')
338
    {
339
        if (false === $contentElse) {
340
            $ret = "{$t}if ({$condition}{$operator}{$type}) {\n";
341
            $ret .= $contentIf;
342
            $ret .= "{$t}}\n";
343
        } else {
344
            $ret = "{$t}if ({$condition}{$operator}{$type}) {\n";
345
            $ret .= $contentIf;
346
            if ('' !== $conditionElse) {
347
                $ret .= "{$t}} elseif ({$conditionElse}) {\n";
348
            } else {
349
                $ret .= "{$t}} else {\n";
350
            }
351
352
            $ret .= $contentElse;
353
            $ret .= "{$t}}\n";
354
        }
355
356
        return $ret;
357
    }
358
359
    /**
360
     * @public function getPhpCodeForeach
361
     * @param string      $array
362
     * @param bool|string $arrayKey
363
     * @param bool|string $key
364
     * @param bool|string $value
365
     * @param string      $content
366
     *
367
     * @param string      $t
368
     * @return string
369
     */
370
    public function getPhpCodeForeach($array, $arrayKey = false, $key = false, $value = false, $content = null, $t = '')
371
    {
372
        $vars  = '';
373
        $value = '' !== $value ? $value : 'i';
374
        if ((false === $arrayKey) && (false === $key)) {
375
            $vars = "\${$array} as \${$value}";
376
        } elseif ((false === $arrayKey) && (false !== $key)) {
377
            $vars = "\${$array} as \${$key} => \${$value}";
378
        } elseif ((false !== $arrayKey) && (false === $key)) {
379
            $vars = "array_keys(\${$array}) as \${$value}";
380
        }
381
382
        $ret = "{$t}foreach({$vars}) {\n";
383
        $ret .= "{$content}";
384
        $ret .= "{$t}}\n";
385
386
        return $ret;
387
    }
388
389
    /**
390
     * @public function getPhpCodeFor
391
     * @param        $var
392
     * @param        $content
393
     * @param        $value
394
     * @param        $initVal
395
     * @param        $operator
396
     *
397
     * @param string $t
398
     * @return string
399
     */
400
    public function getPhpCodeFor($var = null, $content = null, $value = null, $initVal = null, $operator = null, $t = '')
401
    {
402
        $ret = "{$t}for(\${$var} = {$initVal}; \${$var} {$operator} \${$value}; \${$var}++) {\n";
403
        $ret .= "{$content}";
404
        $ret .= "{$t}}\n";
405
406
        return $ret;
407
    }
408
409
    /**
410
     * @public function getPhpCodeWhile
411
     * @param $var
412
     * @param $content
413
     * @param $value
414
     * @param $operator
415
     * @param $t
416
     *
417
     * @return string
418
     */
419
    public function getPhpCodeWhile($var = null, $content = null, $value = null, $operator = null, $t = '')
420
    {
421
        $ret = "{$t}while (\${$var} {$operator} {$value}) {\n";
422
        $ret .= "{$t}{$content}";
423
        $ret .= "{$t}}\n";
424
425
        return $ret;
426
    }
427
428
    /**
429
     * @public function getPhpCodeSwitch
430
     *
431
     * @param $op
432
     * @param $content
433
     * @param $t
434
     *
435
     * @return string
436
     */
437
    public function getPhpCodeSwitch($op = null, $content = null, $t = '')
438
    {
439
        $ret = "{$t}switch(\${$op}) {\n";
440
        $ret .= $content;
441
        $ret .= "{$t}}\n";
442
443
        return $ret;
444
    }
445
446
    /**
447
     * @public function getPhpCodeCaseSwitch
448
     *
449
     * @param $cases
450
     * @param $defaultAfterCase
451
     * @param $default
452
     * @param $t
453
     *
454
     * @return string
455
     */
456
    public function getPhpCodeCaseSwitch($cases = [], $defaultAfterCase = false, $default = false, $t = '')
457
    {
458
        $ret = '';
459
        $def = "{$t}default:\n";
460
        foreach ($cases as $case => $value) {
461
            $case = is_string($case) ? "'{$case}'" : $case;
462
            if (!empty($case)) {
463
                $ret .= "{$t}case {$case}:\n";
464
                if (false !== $defaultAfterCase) {
465
                    $ret .= $def;
466
                }
467
                if (is_array($value)) {
468
                    foreach ($value as $content) {
469
                        $ret .= "{$content}";
470
                    }
471
                }
472
                $ret .= "{$t}break;\n";
473
            }
474
            $defaultAfterCase = false;
475
        }
476
        if (false !== $default) {
477
            $ret .= $def;
478
            $ret .= "{$t}{$default}\n";
479
            $ret .= "{$t}break;\n";
480
        }
481
482
        return $ret;
483
    }
484
485
    /**
486
     * @public function getPhpCodeIsset
487
     * @param $var
488
     * @return string
489
     */
490
    public function getPhpCodeIsset($var)
491
    {
492
        return "isset(\${$var})";
493
    }
494
495
    /**
496
     * @public function getPhpCodeUnset
497
     * @param string $var
498
     * @param string $t
499
     * @return string
500
     */
501
    public function getPhpCodeUnset($var = '', $t = '')
502
    {
503
        return "{$t}unset(\${$var});\n";
504
    }
505
506
    /**
507
     * @public function getPhpCodeIsDir
508
     * @param $var
509
     * @return string
510
     */
511
    public function getPhpCodeIsDir($var)
512
    {
513
        return "is_dir({$var})";
514
    }
515
516
    /**
517
     * @public function getPhpCodeImplode
518
     * @param $left
519
     * @param $right
520
     * @return string
521
     */
522
    public function getPhpCodeImplode($left, $right)
523
    {
524
        return "implode('{$left}', {$right})";
525
    }
526
527
    /**
528
     * @public function getPhpCodeExplode
529
     * @param $left
530
     * @param $right
531
     * @return string
532
     */
533
    public function getPhpCodeExplode($left, $right)
534
    {
535
        return "explode('{$left}', {$right})";
536
    }
537
538
    /**
539
     * @public function getPhpCodeChmod
540
     * @param        $var
541
     * @param string $perm
542
     * @param string $t
543
     * @return string
544
     */
545
    public function getPhpCodeChmod($var, $perm = '0777', $t = '')
546
    {
547
        return "{$t}chmod(\${$var}, {$perm});\n";
548
    }
549
550
    /**
551
     * @public function getPhpCodeMkdir
552
     * @param        $var
553
     * @param string $perm
554
     * @param string $t
555
     * @return string
556
     */
557
    public function getPhpCodeMkdir($var, $perm = '0777', $t = '')
558
    {
559
        return "{$t}mkdir(\${$var}, {$perm});\n";
560
    }
561
562
    /**
563
     * @public function getPhpCodeCopy
564
     * @param        $file
565
     * @param string $newfile
566
     * @param string $t
567
     * @return string
568
     */
569
    public function getPhpCodeCopy($file, $newfile = '', $t = '')
570
    {
571
        return "{$t}copy({$file}, {$newfile});\n";
572
    }
573
574
    /**
575
     * @public function getPhpCodeArray
576
     * @param        $var
577
     * @param        $array
578
     * @param bool   $isParam
579
     *
580
     * @param string $t
581
     * @return string
582
     */
583
    public function getPhpCodeArray($var, $array = null, $isParam = false, $t = "\t\t")
584
    {
585
        $retArray = [];
586
        if (is_array($array) && !empty($array)) {
587
            foreach ($array as $k => $v) {
588
                if (is_numeric($k)) {
589
                    $retArray[] = $v;
590
                } else {
591
                    $retArray[] = "{$k} => {$v}";
592
                }
593
            }
594
            $arrayContent = implode(', ', $retArray);
595
        } else {
596
            $arrayContent = '';
597
        }
598
        unset($retArray);
599
600
        if (!$isParam) {
601
            $ret = "{$t}\${$var} = [{$arrayContent}];\n";
602
        } else {
603
            $ret = "[{$array}]";
604
        }
605
606
        return $ret;
607
    }
608
609
    /**
610
     * @public function getPhpCodeArrayType
611
     * @param        $var
612
     * @param        $type
613
     * @param        $left
614
     * @param        $right
615
     * @param bool   $isParam
616
     *
617
     * @param string $t
618
     * @return string
619
     */
620
    public function getPhpCodeArrayType($var, $type, $left, $right = null, $isParam = false, $t = "\t\t")
621
    {
622
        $vars = (null != $right) ? "\${$left}, {$right}" : "\${$left}";
623
        if (!$isParam) {
624
            $ret = "{$t}\${$var}[] = array_{$type}({$vars});\n";
625
        } else {
626
            $ret = "array_{$type}({$vars})";
627
        }
628
629
        return $ret;
630
    }
631
632
    /**
633
     * @public function getPhpCodeArrayType
634
     * @param        $var
635
     * @param string $t
636
     * @return string
637
     */
638
    public function getPhpCodeArrayShift($var, $t = '')
639
    {
640
        return "{$t}array_shift({$var});\n";
641
    }
642
643
    /**
644
     * @public function getPhpCodeSprintf
645
     * @param $left
646
     * @param $right
647
     * @return string
648
     */
649
    public function getPhpCodeSprintf($left, $right)
650
    {
651
        return "sprintf({$left}, {$right})";
652
    }
653
654
    /**
655
     * @public function getPhpCodeEmpty
656
     * @param $var
657
     * @return string
658
     */
659
    public function getPhpCodeEmpty($var)
660
    {
661
        return "empty({$var})";
662
    }
663
664
    /**
665
     * @public function getPhpCodeHeader
666
     * @param $var
667
     * @return string
668
     */
669
    public function getPhpCodeHeader($var)
670
    {
671
        return "header({$var})";
672
    }
673
674
    /**
675
     * @public function getPhpCodeRawurlencode
676
     * @param $var
677
     * @return string
678
     */
679
    public function getPhpCodeRawurlencode($var)
680
    {
681
        return "rawurlencode({$var})";
682
    }
683
684
    /**
685
     * @public function getPhpCodePregFunzions
686
     * @param        $var
687
     * @param        $exp
688
     * @param        $str
689
     * @param        $val
690
     * @param string $type
691
     * @param bool   $isParam
692
     *
693
     * @param string $t
694
     * @return string
695
     */
696
    public function getPhpCodePregFunzions($var, $exp, $str, $val, $type = 'match', $isParam = false, $t = "\t")
697
    {
698
        $pregFunz = "preg_{$type}('";
699
        if (!$isParam) {
700
            $ret = "{$t}\${$var} = {$pregFunz}{$exp}', '{$str}', {$val});\n";
701
        } else {
702
            $ret = "{$pregFunz}{$exp}', '{$str}', {$val})";
703
        }
704
705
        return $ret;
706
    }
707
708
    /**
709
     * @public function getPhpCodeStrType
710
     * @param        $left
711
     * @param        $var
712
     * @param        $str
713
     * @param        $value
714
     * @param string $type
715
     * @param bool   $isParam
716
     *
717
     * @param string $t
718
     * @return string
719
     */
720
    public function getPhpCodeStrType($left, $var, $str, $value, $type = 'replace', $isParam = false, $t = "\t")
721
    {
722
        $strType = "str_{$type}('";
723
        if (!$isParam) {
724
            $ret = "{$t}\${$left} = {$strType}{$var}', '{$str}', {$value});\n";
725
        } else {
726
            $ret = "{$strType}{$var}', '{$str}', {$value})";
727
        }
728
729
        return $ret;
730
    }
731
732
    /**
733
     * @public function getPhpCodeStripTags
734
     * @param        $left
735
     * @param        $value
736
     * @param bool   $isParam
737
     *
738
     * @param string $t
739
     * @return string
740
     */
741
    public function getPhpCodeStripTags($left, $value, $isParam = false, $t = '')
742
    {
743
        if (!$isParam) {
744
            $ret = "{$t}\${$left} = strip_tags({$value});\n";
745
        } else {
746
            $ret = "strip_tags({$value})";
747
        }
748
749
        return $ret;
750
    }
751
752
    /**
753
     * @public function getPhpCodeHtmlentities
754
     * @param $entitiesVar
755
     * @param $entitiesQuote
756
     * @return string
757
     */
758
    public function getPhpCodeHtmlentities($entitiesVar, $entitiesQuote = false)
759
    {
760
        $entitiesVar = (false !== $entitiesQuote) ? $entitiesVar . ', ' . $entitiesQuote : $entitiesVar;
761
        $entities    = "htmlentities({$entitiesVar})";
762
763
        return $entities;
764
    }
765
766
    /**
767
     * @public function getPhpCodeHtmlspecialchars
768
     * @param $specialVar
769
     * @param $specialQuote
770
     * @return string
771
     */
772
    public function getPhpCodeHtmlspecialchars($specialVar, $specialQuote = false)
773
    {
774
        $specialVar   = (false !== $specialQuote) ? $specialVar . ', ' . $specialQuote : $specialVar;
775
        $specialchars = "htmlspecialchars({$specialVar})";
776
777
        return $specialchars;
778
    }
779
780
    /**
781
     * @public function getPhpCodeNamespace
782
     * @param $dimensions
783
     * @param string $t
784
     * @param string $n
785
     * @return string
786
     */
787
    public function getPhpCodeNamespace($dimensions, $t = '', $n = "\n\n")
788
    {
789
        $ret  = "\n{$t}namespace ";
790
        foreach ($dimensions as $key => $dim) {
791
            if ($key > 0) {
792
                $ucfDim = ucfirst($dim);
793
                $ret .= "\\{$ucfDim}";
794
            } else {
795
                $ret .= "{$dim}";
796
            }
797
        }
798
        $ret .= ";" . $n;
799
800
        return $ret;
801
    }
802
803
    /**
804
     * @public function getPhpCodeUseNamespace
805
     * @param $dimensions
806
     * @param string $t
807
     * @param string $n
808
     * @return string
809
     */
810
    public function getPhpCodeUseNamespace($dimensions, $t = '', $n = "\n\n")
811
    {
812
        $ret  = "\n{$t}use ";
813
        foreach ($dimensions as $key => $dim) {
814
            if ($key > 0) {
815
                $ucfDim = ucfirst($dim);
816
                $ret .= "\\{$ucfDim}";
817
            } else {
818
                $ret .= "{$dim}";
819
            }
820
        }
821
        $ret .= ";" . $n;
822
823
        return $ret;
824
    }
825
    /**
826
     * @public function getPhpCodeBlankLine
827
     *
828
     * @return string
829
     */
830
    public function getPhpCodeBlankLine()
831
    {
832
        return "\n";
833
    }
834
835
    /**
836
     * @public function getPhpCodeConstant
837
     *
838
     * @param $const
839
     * @param $value
840
     * @param string $t
841
     * @param string $type
842
     * @return string
843
     */
844
    public function getPhpCodeConstant($const, $value, $t = '', $type = 'const')
845
    {
846
        return  "{$t}{$type} {$const} = {$value};\n";
847
    }
848
849
    /**
850
     * @public function getPhpCodeTriggerError
851
     *
852
     * @param $msg
853
     * @param $type
854
     * @param string $t
855
     * @return string
856
     */
857
    public function getPhpCodeTriggerError($msg, $type, $t ='')
858
    {
859
        $ret = "{$t}trigger_error($msg, {$type});\n";
860
        return $ret;
861
    }
862
}
863