Passed
Push — master ( 95e0c4...fc8ab0 )
by
unknown
44s queued 15s
created

StepForm   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 4
1
<?php
2
3
namespace XoopsModules\Suico\Form;
4
5
use XoopsModules\Suico;
6
use XoopsModules\Suico\Regstep;
7
use XoopsThemeForm;
8
use XoopsFormButton;
9
use XoopsFormHidden;
10
use XoopsFormLabel;
11
use XoopsFormSelectUser;
12
13
/**
14
 *
15
 * @param Regstep $step {@link Regstep} to edit
16
 * @param bool                        $action
17
 */
18
19
class StepForm extends XoopsThemeForm
20
{
21
    function __construct(Regstep $step = null, $action = false)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
22
    {
23
        if (!$action) {
24
            $action = $_SERVER['REQUEST_URI'];
0 ignored issues
show
Unused Code introduced by
The assignment to $action is dead and can be removed.
Loading history...
25
        }
26
        if (empty($GLOBALS['xoopsConfigUser'])) {
27
            /* @var \XoopsConfigHandler $configHandler */
28
            $configHandler              = xoops_getHandler('config');
29
            $GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER);
30
        }
31
        include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
32
        parent::__construct(_AM_SUICO_STEP, 'stepform', 'step.php', 'post', true);
33
        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

33
        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...
34
            $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

34
            $this->addElement(new XoopsFormHidden('id', /** @scrutinizer ignore-type */ $step->getVar('step_id')));
Loading history...
35
        }
36
        $this->addElement(new XoopsFormHidden('op', 'save'));
37
        $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

37
        $this->addElement(new \XoopsFormText(_AM_SUICO_STEPNAME, 'step_name', 25, 255, /** @scrutinizer ignore-type */ $step->getVar('step_name', 'e')));
Loading history...
38
        $this->addElement(new \XoopsFormText(_AM_SUICO_STEPINTRO, 'step_desc', 25, 255, $step->getVar('step_desc', 'e')));
39
        $this->addElement(new \XoopsFormText(_AM_SUICO_STEPORDER, 'step_order', 10, 10, $step->getVar('step_order', 'e')));
40
        $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

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