FormTab::render()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 28
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 22
nc 5
nop 0
dl 0
loc 28
rs 9.568
c 0
b 0
f 0
1
<?php namespace XoopsModules\Tdmcreate\Form;
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
 * Tab - a form tab.
14
 *
15
 * @category  XoopsFormTab
16
 *
17
 * @author    trabis <[email protected]>
18
 * @copyright 2012-2014 XOOPS Project (https://xoops.org)
19
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
20
 *
21
 * @link      https://xoops.org
22
 * @since     2.0.0
23
 */
24
\XoopsLoad::load('XoopsFormElementTray');
25
26
/**
27
 * Class Tdmcreate\FormTab.
28
 */
29
class FormTab extends \XoopsFormElementTray
30
{
31
    /**
32
     * __construct.
33
     *
34
     * @param string $caption tab caption
35
     * @param string $name    unique identifier for this tab
36
     */
37
    public function __construct($caption, $name)
38
    {
39
        $this->setName($name);
40
        $this->setCaption($caption);
41
    }
42
43
    /**
44
     * render.
45
     *
46
     * @return string
47
     */
48
    public function render()
49
    {
50
        $ret = '';
51
        /* @var $ele \XoopsFormElement */
52
        foreach ($this->getElements() as $ele) {
53
            $ret .= NWLINE;
54
            $ret .= '<tr>'.NWLINE;
55
            $ret .= '<td class="head" width="30%">'.NWLINE;
56
            $required = $ele->isRequired() ? '-required' : '';
57
            $ret .= '<div class="xoops-form-element-caption'.$required.'">'.NWLINE;
58
            $ret .= '<span class="caption-text">'.$ele->getCaption().'</span>'.NWLINE;
59
            $ret .= '<span class="caption-marker">*</span>'.NWLINE;
60
            $ret .= '</div>'.NWLINE;
61
            $description = $ele->getDescription();
62
            if ($description) {
63
                $ret .= '<div style="font-weight: normal">'.NWLINE;
64
                $ret .= $description.NWLINE;
65
                $ret .= '</div>'.NWLINE;
66
            }
67
            $ret .= '</td>'.NWLINE;
68
            $ret .= '<td class="even">'.NWLINE;
69
            $ret .= $ele->render().NWLINE;
0 ignored issues
show
Bug introduced by
Are you sure the usage of $ele->render() targeting XoopsFormElement::render() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
70
            $ret .= '<span class="form-horizontal">'.$ele->getDescription().'</span>';
71
            $ret .= '</td>'.NWLINE;
72
            $ret .= '</tr>'.NWLINE;
73
        }
74
75
        return $ret;
76
    }
77
}
78