FormTab   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 28 4
A __construct() 0 4 1
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Form;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
/**
15
 * Tab - a form tab.
16
 *
17
 * @category  XoopsFormTab
18
 *
19
 * @author    trabis <[email protected]>
20
 * @copyright 2012-2014 XOOPS Project (https://xoops.org)
21
 * @license   GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
22
 *
23
 * @link      https://xoops.org
24
 * @since     2.0.0
25
 */
26
\XoopsLoad::load('XoopsFormElementTray');
27
28
/**
29
 * Class Modulebuilder\FormTab.
30
 */
31
class FormTab extends \XoopsFormElementTray
32
{
33
    /**
34
     * __construct.
35
     *
36
     * @param string $caption tab caption
37
     * @param string $name    unique identifier for this tab
38
     */
39
    public function __construct($caption, $name)
40
    {
41
        $this->setName($name);
42
        $this->setCaption($caption);
43
    }
44
45
    /**
46
     * render.
47
     *
48
     * @return string
49
     */
50
    public function render()
51
    {
52
        $ret = '';
53
        /* @var \XoopsFormElement $ele */
54
        foreach ($this->getElements() as $ele) {
55
            $ret         .= NWLINE;
56
            $ret         .= '<tr>' . NWLINE;
57
            $ret         .= '<td class="head" style="width:30%">' . NWLINE;
58
            $required    = $ele->isRequired() ? '-required' : '';
59
            $ret         .= '<div class="xoops-form-element-caption' . $required . '">' . NWLINE;
60
            $ret         .= '<span class="caption-text">' . $ele->getCaption() . '</span>' . NWLINE;
61
            $ret         .= '<span class="caption-marker">*</span>' . NWLINE;
62
            $ret         .= '</div>' . NWLINE;
63
            $description = $ele->getDescription();
64
            if ($description) {
65
                $ret .= '<div style="font-weight: normal">' . NWLINE;
66
                $ret .= $description . NWLINE;
67
                $ret .= '</div>' . NWLINE;
68
            }
69
            $ret .= '</td>' . NWLINE;
70
            $ret .= '<td class="even">' . NWLINE;
71
            $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...
72
            $ret .= '<span class="form-horizontal">' . $ele->getDescription() . '</span>';
73
            $ret .= '</td>' . NWLINE;
74
            $ret .= '</tr>' . NWLINE;
75
        }
76
77
        return $ret;
78
    }
79
}
80