CustomerServiceBlock   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 56
ccs 12
cts 18
cp 0.6667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A singular_name() 0 4 1
A plural_name() 0 4 1
B getCMSFields() 0 24 2
1
<?php
2
3
class CustomerServiceBlock extends Block
4
{
5
    /**
6
     * @return string
7
     */
8 12
    public function singular_name()
9
    {
10 12
        return _t('CustomerServiceBlock.SINGULARNAME', 'Customer Service Block');
11
    }
12
13
    /**
14
     * @return string
15
     */
16 1
    public function plural_name()
17
    {
18 1
        return _t('CustomerServiceBlock.PLURALNAME', 'Customer Service Blocks');
19
    }
20
21
    /**
22
     * @var array
23
     */
24
    private static $db = array(
25
        'Title' => 'Varchar(255)',
26
        'Website' => 'Varchar(255)',
27
        'Phone' => 'Varchar(40)',
28
        'Email' => 'Varchar(255)',
29
    );
30
31
    /**
32
     * @return FieldList
33
     */
34 1
    public function getCMSFields()
35
    {
36 1
        $fields = parent::getCMSFields();
37
38 1
        $self =& $this;
39
40
        $this->beforeUpdateCMSFields(function ($fields) use ($self) {
41
            $fields->dataFieldByName('Title')
42
                ->setTitle('Name');
43
            
44
            if ($website = $fields->dataFieldByName('Website')) {
45
                $website->setAttribute('placeholder', 'http://');
46
            }
47
48
            $fields->replaceField('Email', EmailField::create('Email'));
49 1
        });
50
51 1
        $fields->dataFieldByName('Suburb')
52 1
            ->setTitle('City');
53
54 1
        $fields->replaceField('Country', CountryDropdownField::create('Country'));
55
56 1
        return $fields;
57
    }
58
}