ContactUsPageDataExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 36
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 19 1
1
<?php
2
3
class ContactUsPageDataExtension extends Extension
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...
4
{
5
6
    private static $has_many = [
0 ignored issues
show
Unused Code introduced by
The property $has_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
7
        'ContactUsFormEntries' => 'ContactUsFormEntry'
8
    ];
9
10
    private static $field_labels = [
0 ignored issues
show
Unused Code introduced by
The property $field_labels is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
11
        'ContactUsFormEntries' => 'Contact Us Form Entries'
12
    ];
13
14
15
    /**
16
     * Update Fields
17
     * @return FieldList
18
     */
19
    public function updateCMSFields(FieldList $fields)
20
    {
21
        $owner = $this->owner;
0 ignored issues
show
Unused Code introduced by
$owner is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
22
        $fieldLabels = $this->owner->FieldLabels();
23
        $label = $fieldLabels['ContactUsFormEntries'];
24
        $fields->addFieldToTab(
25
            'Root.ContactForm',
26
            GridField::create(
27
                'ContactUsFormEntries',
28
                $label,
29
                $this->owner->ContactUsFormEntries(),
30
                $config = GridFieldConfig_RelationEditor::create()
31
            )
32
        );
33
        $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
34
        $config->removeComponentsByType('GridFieldDeleteAction');
35
36
        return $fields;
37
    }
38
}
39