BlockForm::render()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 14
nc 6
nop 0
dl 0
loc 22
rs 9.2222
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Tag;
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
/**
16
 * XOOPS tag management module
17
 *
18
 * @copyright       {@link https://sourceforge.net/projects/xoops/ The XOOPS Project}
19
 * @license         {@link https://www.fsf.org/copyleft/gpl.html GNU public license}
20
 * @author          Taiwen Jiang <[email protected]>
21
 * @author          susheng yang <[email protected]>
22
 * @since           2.33
23
 */
24
require_once $GLOBALS['xoops']->path('/class/xoopsformloader.php');
25
26
/**
27
 * Class BlockForm
28
 */
29
class BlockForm extends \XoopsForm
30
{
31
    /**
32
     * create HTML to output the form as a table
33
     *
34
     * @return string HTML div containing element
35
     */
36
    public function render(): string
37
    {
38
        //        $ele_name = $this->getName();
39
        $ret    = "<div>\n";
40
        $hidden = '';
41
        foreach ($this->getElements() as $ele) {
42
            if (!\is_object($ele)) {
43
                $ret .= $ele;
44
            } elseif ($ele->isHidden()) {
45
                $hidden .= $ele->render();
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...
46
            } else {
47
                if ('' != ($caption = $ele->getCaption())) {
48
                    $ret .= "<div class='xoops-form-element-caption" . ($ele->isRequired() ? '-required' : '') . "'>\n" . "  <span class='caption-text'>{$caption}</span>\n" . "  <span class='caption-marker'>*</span>\n" . "</div>\n";
49
                }
50
51
                $ret .= "<div style='margin:5px 0 8px 0; '>" . $ele->render() . "</div>\n";
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...
52
            }
53
        }
54
        $ret .= "</div>\n";
55
        $ret .= $this->renderValidationJS(true);
56
57
        return $ret;
58
    }
59
}
60