Test Failed
Push — master ( 194522...eda1b6 )
by Mikael
01:43
created

FormModelElementsHTML401::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 99
Code Lines 66

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 66
nc 1
nop 0
dl 0
loc 99
rs 8.3103
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Anax\HTMLForm;
4
5
/**
6
 * Example of FormModel implementation.
7
 */
8
class FormModelElementsHTML401 extends FormModel
9
{
10
    /**
11
     * Constructor
12
     */
13
    public function __construct()
14
    {
15
        parent::__construct(
16
            [
17
                "legend" => "Legend",
18
            ],
19
            [
20
                "text" => [
21
                    "type"        => "text",
22
                    "description" => "Here you can place a description.",
23
                    "placeholder" => "Here is a placeholder",
24
                ],
25
                        
26
                "password" => [
27
                    "type"        => "password",
28
                    "description" => "Here you can place a description.",
29
                    "placeholder" => "Here is a placeholder",
30
                ],
31
32
                "hidden" => [
33
                    "type"        => "hidden",
34
                    "value"       => "secret value",
35
                ],
36
37
                "file" => [
38
                    "type"        => "file",
39
                    "description" => "Here you can place a description.",
40
                ],
41
42
                "textarea" => [
43
                    "type"        => "textarea",
44
                    "description" => "Here you can place a description.",
45
                    "placeholder" => "Here is a placeholder",
46
                ],
47
48
                "radio" => [
49
                    "type"        => "radio",
50
                    "label"       => "What is your preferred choice of fruite?",
51
                    "description" => "Here you can place a description.",
52
                    "values"      => [
53
                        "tomato",
54
                        "potato",
55
                        "apple",
56
                        "pear",
57
                        "banana"
58
                    ],
59
                    "checked"     => "potato",
60
                ],
61
62
                "checkbox" => [
63
                    "type"        => "checkbox",
64
                    "description" => "Here you can place a description.",
65
                ],
66
67
                "select" => [
68
                    "type"        => "select",
69
                    "label"       => "Select your fruite:",
70
                    "description" => "Here you can place a description.",
71
                    "options"     => [
72
                        "tomato" => "tomato",
73
                        "potato" => "potato",
74
                        "apple"  => "apple",
75
                        "pear"   => "pear",
76
                        "banana" => "banana",
77
                    ],
78
                    "value"    => "potato",
79
                ],
80
81
                "selectm" => [
82
                    "type"        => "select-multiple",
83
                    "label"       => "Select one or more fruite:",
84
                    "description" => "Here you can place a description.",
85
                    "size"        => 6,
86
                    "options"     => [
87
                        "tomato" => "tomato",
88
                        "potato" => "potato",
89
                        "apple"  => "apple",
90
                        "pear"   => "pear",
91
                        "banana" => "banana",
92
                    ],
93
                    "checked"   => ["potato", "pear"],
94
                ],
95
96
                "reset" => [
97
                    "type"      => "reset",
98
                ],
99
100
                "button" => [
101
                    "type"      => "button",
102
                ],
103
104
                "submit" => [
105
                    "type" => "submit",
106
                    "value" => "Submit",
107
                    "callback" => [$this, "callbackSubmit"]
108
                ],
109
            ]
110
        );
111
    }
112
113
114
115
    /**
116
     * Callback for submit-button.
117
     */
118 View Code Duplication
    public function callbackSubmit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
119
    {
120
        $this->AddOutput("<p>#callbackSubmit()</p>");
121
        $this->AddOutput("<pre>" . print_r($_POST, 1) . "</pre>");
122
        $this->saveInSession = true;
0 ignored issues
show
Bug introduced by
The property saveInSession does not seem to exist. Did you mean session?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
123
124
        return true;
125
    }
126
}
127