GoogleAnalyticsSiteConfigExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 2 Features 2
Metric Value
wmc 1
c 3
b 2
f 2
lcom 0
cbo 3
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 14 1
1
<?php namespace StudioBonito\SilverStripe\GoogleAnalytics\Extensions;
2
3
use FieldList;
4
use TextField;
5
6
/**
7
 * GoogleAnalyticsSiteConfigExtension.
8
 *
9
 * @author       Tom Densham <[email protected]>
10
 * @copyright    Studio Bonito Ltd.
11
 */
12
class GoogleAnalyticsSiteConfigExtension extends \DataExtension
13
{
14
    /**
15
     * List of database fields. {@link DataObject::$db}
16
     *
17
     * @var array
18
     */
19
    private static $db = array(
0 ignored issues
show
Unused Code introduced by
The property $db 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...
20
        'GoogleAnalyticsTrackingID' => 'Varchar(16)',
21
    );
22
23
    /**
24
     * Update list of fields in SiteConfig. Adds all fields inside `Services` parent tab.
25
     *
26
     * @param FieldList $fields
27
     */
28 3
    public function updateCMSFields(FieldList $fields)
29
    {
30 3
        $fields->addFieldsToTab(
31 3
            'Root.Services.GoogleAnalytics',
32
            array(
33 3
                $trackingIdTextField = new TextField(
34 3
                    'GoogleAnalyticsTrackingID',
35 3
                    _t('GoogleAnalytics.TRACKINGID', 'Tracking ID')
36 3
                )
37 3
            )
38 3
        );
39
40 3
        $trackingIdTextField->setDescription(_t('GoogleAnalytics.TRACKINGID_DESC', 'e.g. \'UA-12345678-1\''));
41
    }
42
}