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

FormModelElementsHTML5   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 129
Duplicated Lines 6.2 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 8
loc 129
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 107 1
A callbackSubmit() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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