SimpleForm   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 14 4
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Form;
4
5
/**
6
 * XOOPS simple form.
7
 *
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 *
15
 * @copyright       XOOPS Project (https://xoops.org)
16
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.0.0
19
 *
20
 * @author          Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
21
 *
22
 */
23
\defined('XOOPS_ROOT_PATH') || die('Restricted access');
24
25
/*
26
 * base class
27
 */
28
29
\XoopsLoad::load('XoopsFormLoader');
30
31
/**
32
 * Form that will output as a simple HTML form with minimum formatting.
33
 */
34
class SimpleForm extends \XoopsForm
35
{
36
    /**
37
     * create HTML to output the form with minimal formatting.
38
     *
39
     * @return string
40
     */
41
    public function render()
42
    {
43
        $ret = ($this->getTitle() ? '<div class=" center head ">' . $this->getTitle() . '</div>' : '');
44
        $ret .= '<form name="' . $this->getName() . '" id="' . $this->getName() . '" action="' . $this->getAction() . '" method="' . $this->getMethod() . '"' . $this->getExtra() . '>' . NWLINE;
45
        foreach ($this->getElements() as $ele) {
46
            if (!$ele->isHidden()) {
47
                $ret .= '<div class="' . $ele->getClass() . '"><strong>' . $ele->getCaption() . '</strong>' . $ele->render() . '</div>' . 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...
Bug introduced by
Are you sure $ele->getClass() of type false|string can be used in concatenation? ( Ignorable by Annotation )

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

47
                $ret .= '<div class="' . /** @scrutinizer ignore-type */ $ele->getClass() . '"><strong>' . $ele->getCaption() . '</strong>' . $ele->render() . '</div>' . NWLINE;
Loading history...
48
            } else {
49
                $ret .= $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...
50
            }
51
        }
52
        $ret .= NWLINE . '</form>';
53
54
        return $ret;
55
    }
56
}
57