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

FormModelElementsHTML5::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 107
Code Lines 69

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 69
nc 1
nop 0
dl 0
loc 107
rs 8.2857
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 FormModelElementsHTML5 extends FormModel
9
{
10
    /**
11
     * Constructor
12
     *
13
     */
14
    public function __construct()
15
    {
16
        parent::__construct(
17
            [
18
                "legend" => "Legend"
19
            ],
20
            [
21
                "color" => [
22
                    "type"        => "color",
23
                    "description" => "Here you can place a description.",
24
                    "placeholder" => "Here is a placeholder",
25
                ],
26
27
                "date" => [
28
                    "type"        => "date",
29
                    "description" => "Here you can place a description.",
30
                    "placeholder" => "Here is a placeholder",
31
                ],
32
33
                "datetime" => [
34
                    "type"        => "datetime",
35
                    "description" => "Here you can place a description.",
36
                    "placeholder" => "Here is a placeholder",
37
                ],
38
39
                "datetime-local" => [
40
                    "type"        => "datetime-local",
41
                    "description" => "Here you can place a description.",
42
                    "placeholder" => "Here is a placeholder",
43
                ],
44
45
                "time" => [
46
                    "type"        => "time",
47
                    "description" => "Here you can place a description.",
48
                    "placeholder" => "Here is a placeholder",
49
                ],
50
51
                "week" => [
52
                    "type"        => "week",
53
                    "description" => "Here you can place a description.",
54
                    "placeholder" => "Here is a placeholder",
55
                ],
56
57
                "month" => [
58
                    "type"        => "month",
59
                    "description" => "Here you can place a description.",
60
                    "placeholder" => "Here is a placeholder",
61
                ],
62
63
                "number" => [
64
                    "type"        => "number",
65
                    "description" => "Here you can place a description.",
66
                    "placeholder" => "Here is a placeholder",
67
                ],
68
69
                "range" => [
70
                    "type"        => "range",
71
                    "description" => "Here you can place a description.",
72
                    "placeholder" => "Here is a placeholder",
73
                    "value"       => 42,
74
                    "min"         => 0,
75
                    "max"         => 100,
76
                    "step"        => 2,
77
                ],
78
79
                "search" => [
80
                    "type"        => "search",
81
                    "label"       => "Search:",
82
                    "description" => "Here you can place a description.",
83
                    "placeholder" => "Here is a placeholder",
84
                ],
85
86
                "tel" => [
87
                    "type"        => "tel",
88
                    "description" => "Here you can place a description.",
89
                    "placeholder" => "Here is a placeholder",
90
                ],
91
92
                "email" => [
93
                    "type"        => "email",
94
                    "description" => "Here you can place a description.",
95
                    "placeholder" => "Here is a placeholder",
96
                ],
97
98
                "url" => [
99
                    "type"        => "url",
100
                    "description" => "Here you can place a description.",
101
                    "placeholder" => "Here is a placeholder",
102
                ],
103
104
                "file-multiple" => [
105
                    "type"        => "file-multiple",
106
                    "description" => "Here you can place a description.",
107
                ],
108
109
                "reset" => [
110
                    "type"      => "reset",
111
                ],
112
113
                "submit" => [
114
                    "type" => "submit",
115
                    "value" => "Submit",
116
                    "callback" => [$this, "callbackSubmit"]
117
                ],
118
            ]
119
        );
120
    }
121
122
123
124
    /**
125
     * Callback for submit-button.
126
     *
127
     */
128 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...
129
    {
130
        $this->AddOutput("<p>#callbackSubmit()</p>");
131
        $this->AddOutput("<pre>" . print_r($_POST, 1) . "</pre>");
132
        $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...
133
134
        return true;
135
    }
136
}
137