Completed
Push — master ( 3aa853...a4d8e0 )
by Nicolaas
01:29
created

TypographyTestForm   C

Complexity

Total Complexity 1

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 20

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 20
dl 0
loc 96
rs 6.4705
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 91 1
1
<?php
2
3
4
class TypographyTestForm extends Form
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
5
{
6
7
    function __construct($controller, $nameOfForm = 'TestForm')
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...
8
    {
9
        $array = array();
10
        $array[] = "green";
11
        $array[] = "yellow";
12
        $array[] = "blue";
13
        $array[] = "pink";
14
        $array[] = "orange";
15
        $errorField0 = new TextField($name = "ErrorField0", $title = "Text Field Example 1");
16
        $errorField0->setError("message shown when something is good", "good");
17
        $errorField1 = new TextField($name = "ErrorField1", $title = "Text Field Example 2");
18
        $errorField1->setError("message shown when something is bad", "bad");
19
        $errorField2 = new TextField($name = "ErrorField2", $title = "Text Field Example 3");
20
        $errorField2->setCustomValidationMessage("message shown when something is bad", "bad");
0 ignored issues
show
Unused Code introduced by
The call to TextField::setCustomValidationMessage() has too many arguments starting with 'bad'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
21
        $errorField3 = new TextField($name = "ErrorField3", $title = "Text Field Example 4");
22
        $errorField3->setError("there is an error", "required");
23
        $errorField4 = new TextField($name = "ErrorField4", $title = "Text Field Example 5");
24
        $errorField4->setCustomValidationMessage("custom validation error");
25
        $rightTitle = new TextField($name = "RightTitleField", $title = "Left Title is Default");
26
        $rightTitle->setRightTitle("right title here");
27
        $readonlyField = new ReadOnlyField($name = "ReadOnlyField", $title = "ReadOnlyField");
28
        $readonlyField->setValue("read only value");
29
        $groupedDropdownField = new GroupedDropdownField(
30
             $name = "dropdown",
31
             $title = "Simple Grouped Dropdown",
32
             $source = array(
33
                    "primary" => array(
34
                            "1" => "Green",
35
                            "2" => "Red",
36
                            "3" => "Blue",
37
                            "4" => "Orange"
38
                    ),
39
                    "secondary" => array(
40
                            "11" => "Light Blue",
41
                            "12" => "Dark Brown",
42
                            "13" => "Pinkish Red"
43
                    )
44
             )
45
        );
46
        $returnResult = parent::__construct(
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $returnResult is correct as parent::__construct($con...', 'CheckboxSetField')) (which targets Form::__construct()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
47
            $controller,
48
            $nameOfForm,
49
            $fields = new FieldList(
50
                // List the your fields here
51
                new LiteralField($name = "HeaderFieldForForm", $title = '<h1 id="Form">Form Elements</h1>'),
52
                new HeaderField($name = "HeaderField1", $title = "Default Header Field"),
53
                new LiteralField($name = "LiteralField", "<p>NOTE: All fields up to EmailField are required and should be marked as such</p>"),
54
                new TextField($name = "TextField1", $title = "Text Field Example 1"),
55
                new TextField($name = "TextField2", $title = "Text Field Example 2"),
56
                new TextField($name = "TextField3", $title = "Text Field Example 3"),
57
                new TextField($name = "TextField4", $title = ""),
58
                new HeaderField($name = "HeaderField2a", $title = "Error Messages", 2),
59
                new LiteralField($name = "ErrorExplanations", '<p>Below are some error messages, some of them only show up after you have placed your cursor on the field and not completed it (i.e. a reminder to complete the field)</p>'),
60
                $errorField0,
61
                $errorField1,
62
                $errorField2,
63
                $errorField3,
64
                $errorField4,
65
                new HeaderField($name = "HeaderField2b", $title = "Field with right title", 2),
66
                $rightTitle,
67
                $textAreaField = new TextareaField($name = "TextareaField", $title = "Textarea Field"),
68
                new EmailField("EmailField", "Email address"),
69
                new HeaderField($name = "HeaderField2c", $title = "HeaderField Level 2", 2),
70
                new DropdownField($name = "DropdownField", $title = "Dropdown Field", array( 0 => "-- please select --", 1 => "test AAAA", 2 => "test BBBB")),
71
                new OptionsetField($name = "OptionsetField", $title = "Optionset Field", $array),
72
                new CheckboxSetField($name = "CheckboxSetField", $title = "Checkbox Set Field", $array),
73
                new CurrencyField($name = "CurrencyField", $title = "Bling bling"),
74
                new HeaderField($name = "HeaderField3", $title = "Other Fields", 3),
75
                new NumericField($name = "NumericField", $title = "Numeric Field "),
76
                new DateField($name = "DateField", $title = "Date Field"),
77
                new DateField($name = "DateTimeField", $title = "Date and Time Field"),
78
                new FileField($name = "FileField", $title = "File Field"),
79
                new ConfirmedPasswordField($name = "ConfirmPasswordField", $title = "Password"),
80
                new CheckboxField($name = "CheckboxField", $title = "Checkbox Field"),
81
                $groupedDropdownField,
82
                new HeaderField($name = "HeaderField4", $title = "Read-only Field", 3),
83
                $readonlyField
84
            ),
85
            $actions = new FieldList(
86
                    // List the action buttons here
87
                    new FormAction("signup", "Sign up")
88
            ),
89
            $requiredFields = new RequiredFields(
90
                "TextField1", "TextField2", "TextField3", "ErrorField1", "ErrorField2", "EmailField", "TextField3", "RightTitleField", "CheckboxField", "CheckboxSetField"
91
            )
92
        );
93
        $textAreaField->setColumns(7);
94
        $this->setMessage("warning message", "warning");
95
96
        return $returnResult;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
97
    }
98
99
}
100