DynamicBlocksSiteTreeDataExtension   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 20%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 25
ccs 3
cts 15
cp 0.2
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B updateCMSFields() 0 19 5
1
<?php
2
3
class DynamicBlocksSiteTreeDataExtension extends DataExtension
4
{
5
    /**
6
     * @param FieldList $fields
7
     */
8 1
    public function updateCMSFields(FieldList $fields)
9
    {
10 1
        if ($blocks = $fields->dataFieldByName('Blocks')) {
11
            $config = $blocks->getConfig();
0 ignored issues
show
Bug introduced by
The method getConfig() does not exist on FormField. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
12
13
            if ($this->owner->blockManager) {
14
                $areas = $this->owner->blockManager->getAreasForPageType($this->owner->ClassName);
15
16
                if ($areas && count($areas)) {
17
                    $config->addComponent(new GridFieldGroupable(
18
                        'BlockArea',
19
                        'Area',
20
                        'none',
21
                        $areas
22
                    ));
23
                }
24
            }
25
        }
26
    }
27
}