Passed
Pull Request — master (#145)
by Goffy
04:27
created

LanguageDefines   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 91
rs 10
c 0
b 0
f 0
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getAboveDefines() 0 3 1
A getBelowDefines() 0 3 1
A getDefine() 0 11 2
A __construct() 0 3 1
A getAboveHeadDefines() 0 3 1
A getInstance() 0 8 2
A getBlankLine() 0 3 1
1
<?php
2
3
namespace XoopsModules\Tdmcreate\Files\Language;
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 LanguageDefines.
30
 */
31
class LanguageDefines
32
{
33
    /**
34
     * @var mixed
35
     */
36
    protected $defines;
37
38
    /**
39
     * @public function constructor
40
     * @param null
41
     */
42
    public function __construct()
43
    {
44
        $this->phpcode = Tdmcreate\Files\CreatePhpCode::getInstance();
0 ignored issues
show
Bug Best Practice introduced by
The property phpcode does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
45
    }
46
47
    /**
48
     * @static function getInstance
49
     * @param null
50
     * @return LanguageDefines
51
     */
52
    public static function getInstance()
53
    {
54
        static $instance = false;
55
        if (!$instance) {
56
            $instance = new self();
57
        }
58
59
        return $instance;
60
    }
61
62
    /**
63
     * @public function getAboveHeadDefines
64
     * @param string $string
65
     * @return string
66
     */
67
    public function getAboveHeadDefines($string)
68
    {
69
        return "// ---------------- {$string} ----------------\n";
70
    }
71
72
    /**
73
     * @public function getAboveDefines
74
     * @param string $string
75
     * @return string
76
     */
77
    public function getAboveDefines($string)
78
    {
79
        return "// {$string}\n";
80
    }
81
82
    /**
83
     * @public function getDefine
84
     * @param string $language
85
     * @param string $defined
86
     * @param string $description
87
     * @param bool   $usedoubleqoute
88
     * @return string
89
     */
90
    public function getDefine($language, $defined, $description, $usedoubleqoute = false)
91
    {
92
        $defined = mb_strtoupper($defined);
93
94
        if ($usedoubleqoute) {
95
            $ret = $this->phpcode->getPhpCodeDefine("{$language}{$defined}", "\"{$description}\"");
96
        } else {
97
            $ret = $this->phpcode->getPhpCodeDefine("{$language}{$defined}", "'" . $description . "'");
98
        }
99
100
        return $ret;
101
    }
102
103
    /**
104
     * @public function getBelowDefines
105
     * @param string $string
106
     *
107
     * @return string
108
     */
109
    public function getBelowDefines($string)
110
    {
111
        return "// ---------------- {$string} ----------------";
112
    }
113
114
    /**
115
     * @public function getBelowDefines
116
     *
117
     * @return string
118
     */
119
    public function getBlankLine()
120
    {
121
        return "\n";
122
    }
123
}
124