BlockForm   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A render() 0 22 6
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Publisher;
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
 *  Publisher class
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         https://www.fsf.org/copyleft/gpl.html GNU public license
20
 * @since           1.0
21
 * @author          trabis <[email protected]>
22
 */
23
\xoops_load('XoopsForm');
24
25
/**
26
 * Form that will output formatted as a HTML table
27
 *
28
 * No styles and no JavaScript to check for required fields.
29
 */
30
class BlockForm extends \XoopsForm
31
{
32
    public function __construct()
33
    {
34
        parent::__construct('', '', '');
35
    }
36
37
    /**
38
     * create HTML to output the form as a table
39
     *
40
     * YOU SHOULD AVOID TO USE THE FOLLOWING Nocolspan METHOD, IT WILL BE REMOVED
41
     *
42
     * To use the noColspan simply use the following example:
43
     *
44
     * $colspan = new \XoopsFormDhtmlTextArea( '', 'key', $value );
45
     * $colspan->setNocolspan();
46
     * $form->addElement( $colspan );
47
     *
48
     * @return string
49
     */
50
    public function render()
51
    {
52
        $ret = '<table border="0" width="100%">' . NWLINE;
53
        foreach ($this->getElements() as $ele) {
54
            if (!$ele->isHidden()) {
55
                if ($ele->getNocolspan()) {
0 ignored issues
show
Deprecated Code introduced by
The function XoopsFormElement::getNocolspan() has been deprecated: PLEASE AVOID USING THIS METHOD ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
                if (/** @scrutinizer ignore-deprecated */ $ele->getNocolspan()) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
56
                    $ret .= '<tr><td colspan="2">';
57
                    $ret .= '<span style="font-weight: bold;">' . $ele->getCaption() . '</span>';
58
                    $ret .= '</td></tr><tr><td>' . $ele->render() . '</td></tr>';
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...
59
                } else {
60
                    $ret .= '<tr><td style="vertical-align: top; width: 250px;">';
61
                    $ret .= '<span style="font-weight: bold;">' . $ele->getCaption() . '</span>';
62
                    if (isset($eleDesc) && $eleDesc == $ele->getDescription()) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $eleDesc seems to never exist and therefore isset should always be false.
Loading history...
63
                        $ret .= '<br><br><span style="font-weight: normal;">' . $eleDesc . '</span>';
64
                    }
65
                    $ret .= '</td><td>' . $ele->render() . '</td></tr>';
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...
66
                }
67
            }
68
        }
69
        $ret .= '</table>';
70
71
        return $ret;
72
    }
73
}
74