StepForm   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 27
rs 10
c 1
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 4
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Suico\Form;
4
5
use XoopsFormButton;
6
use XoopsFormHidden;
7
use XoopsModules\Suico\Regstep;
8
use XoopsThemeForm;
9
10
/**
11
 * @param Regstep $step {@link Regstep} to edit
12
 * @param bool    $action
13
 */
14
class StepForm extends XoopsThemeForm
15
{
16
    /**
17
     * StepForm constructor.
18
     * @param bool $action
19
     */
20
    public function __construct(Regstep $step = null, $action = false)
21
    {
22
        if (!$action) {
23
            $action = $_SERVER['REQUEST_URI'];
0 ignored issues
show
Unused Code introduced by
The assignment to $action is dead and can be removed.
Loading history...
24
        }
25
        if (empty($GLOBALS['xoopsConfigUser'])) {
26
            /** @var \XoopsConfigHandler $configHandler */
27
            $configHandler              = \xoops_getHandler('config');
28
            $GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(\XOOPS_CONF_USER);
29
        }
30
        require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
31
        parent::__construct(\_AM_SUICO_STEP, 'stepform', 'step.php', 'post', true);
32
        if (!$step->isNew()) {
0 ignored issues
show
Bug introduced by
The method isNew() does not exist on null. ( Ignorable by Annotation )

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

32
        if (!$step->/** @scrutinizer ignore-call */ isNew()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
            $this->addElement(new XoopsFormHidden('id', $step->getVar('step_id')));
0 ignored issues
show
Bug introduced by
It seems like $step->getVar('step_id') can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

33
            $this->addElement(new XoopsFormHidden('id', /** @scrutinizer ignore-type */ $step->getVar('step_id')));
Loading history...
34
        }
35
        $this->addElement(new XoopsFormHidden('op', 'save'));
36
        $this->addElement(new \XoopsFormText(\_AM_SUICO_STEPNAME, 'step_name', 25, 255, $step->getVar('step_name', 'e')));
0 ignored issues
show
Bug introduced by
It seems like $step->getVar('step_name', 'e') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

36
        $this->addElement(new \XoopsFormText(\_AM_SUICO_STEPNAME, 'step_name', 25, 255, /** @scrutinizer ignore-type */ $step->getVar('step_name', 'e')));
Loading history...
37
        $this->addElement(new \XoopsFormText(\_AM_SUICO_STEPINTRO, 'step_desc', 25, 255, $step->getVar('step_desc', 'e')));
38
        $this->addElement(new \XoopsFormText(\_AM_SUICO_STEPORDER, 'step_order', 10, 10, $step->getVar('step_order', 'e')));
39
        $this->addElement(new \XoopsFormRadioYN(\_AM_SUICO_STEPSAVE, 'step_save', $step->getVar('step_save', 'e')));
0 ignored issues
show
Bug introduced by
It seems like $step->getVar('step_save', 'e') can also be of type array and array; however, parameter $value of XoopsFormRadioYN::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

39
        $this->addElement(new \XoopsFormRadioYN(\_AM_SUICO_STEPSAVE, 'step_save', /** @scrutinizer ignore-type */ $step->getVar('step_save', 'e')));
Loading history...
40
        $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit'));
41
    }
42
}
43