Passed
Push — master ( 0f0f99...fb91d6 )
by Michael
17s
created

TemplatesUserSingle::getTemplatesUserSingleBody()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 1
eloc 10
nc 1
nop 3
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tdmcreate module.
14
 *
15
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: TemplatesUserSingle.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class TemplatesUserSingle.
27
 */
28
class TemplatesUserSingle extends TDMCreateFile
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
29
{
30
    /*
31
    * @var string
32
    */
33
    private $tdmcfile = null;
34
35
    /*
36
    *  @public function constructor
37
    *  @param null
38
    */
39
    /**
40
     *
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
        $this->tdmcfile = TDMCreateFile::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \TDMCreateFile::getInstance() of type object<TDMCreateFile> is incompatible with the declared type string of property $tdmcfile.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
    }
47
48
    /*
49
    *  @static function &getInstance
50
    *  @param null
51
    */
52
    /**
53
     * @return TemplatesUserSingle
54
     */
55
    public static function &getInstance()
56
    {
57
        static $instance = false;
58
        if (!$instance) {
59
            $instance = new self();
60
        }
61
62
        return $instance;
63
    }
64
65
    /*
66
    *  @public function write
67
    *  @param string $module
68
    *  @param string $table
69
    *  @param string $filename
70
    */
71
    /**
72
     * @param $module
73
     * @param $table
74
     */
75
    public function write($module, $table)
76
    {
77
        $this->setModule($module);
78
        $this->setTable($table);
79
    }
80
81
    /*
82
    *  @private function getTemplatesUserSingleHeader
83
    *  @param string $language
84
    */
85
    /**
86
     * @param $language
87
     *
88
     * @return string
89
     */
90
    private function getTemplatesUserSingleHeader($moduleDirname)
91
    {
92
        $smarty = TDMCreateSmartyCode::getInstance();
93
        $ret = $smarty->getSmartyIncludeFile($moduleDirname, 'single');
94
95
        return $ret;
96
    }
97
98
    /*
99
    *  @private function getTemplatesUserSingleBody
100
    *  @param string $moduleDirname
101
    *  @param string $table
102
    *  @param string $language
103
    */
104
    /**
105
     * @param $moduleDirname
106
     * @param $table
107
     * @param $language
108
     *
109
     * @return string
110
     */
111
    private function getTemplatesUserSingleBody($moduleDirname, $table, $language)
0 ignored issues
show
Unused Code introduced by
The parameter $language is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $moduleDirname is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
112
    {
113
        $tableName = $table->getVar('table_name');
0 ignored issues
show
Unused Code introduced by
$tableName is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
114
        $hc = TDMCreateHtmlCode::getInstance();
115
        $t = "\t";
116
        $ret = '';
117
        $content = $hc->getHtmlHNumb('Services Panels', '2', 'page-header', $t."\t");
118
        $collg12 = $hc->getHtmlDiv($content, 'col-lg-12', $t);
119
        $row = $hc->getHtmlDiv($collg12, 'row', $t);
120
        $ret .= $hc->getHtmlDiv($row, 'container');
121
122
        return $ret;
123
    }
124
125
    /*
126
    *  @private function getTemplatesUserSingleFooter
127
    *  @param string $moduleDirname
128
    */
129
    /**
130
     * @param $moduleDirname
131
     *
132
     * @return string
133
     */
134
    private function getTemplatesUserSingleFooter($moduleDirname)
135
    {
136
        $smarty = TDMCreateSmartyCode::getInstance();
137
        $ret = $smarty->getSmartyIncludeFile($moduleDirname, 'footer');
138
139
        return $ret;
140
    }
141
142
    /*
143
    *  @public function renderFile
144
    *  @param string $filename
145
    */
146
    /**
147
     * @param $filename
148
     *
149
     * @return bool|string
150
     */
151
    public function renderFile($filename)
152
    {
153
        $module = $this->getModule();
154
        $table = $this->getTable();
155
        $moduleDirname = $module->getVar('mod_dirname');
156
        $language = $this->getLanguage($moduleDirname, 'MA');
157
        $content = $this->getTemplatesUserSingleHeader($moduleDirname);
158
        $content .= $this->getTemplatesUserSingleBody($moduleDirname, $table, $language);
159
        $content .= $this->getTemplatesUserSingleFooter($moduleDirname);
160
        //
161
        $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
0 ignored issues
show
Bug introduced by
The method create cannot be called on $this->tdmcfile (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
162
163
        return $this->tdmcfile->renderFile();
0 ignored issues
show
Bug introduced by
The method renderFile cannot be called on $this->tdmcfile (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
164
    }
165
}
166