Passed
Branch 4 (f3d551)
by Simon
03:46
created

SiteConfigExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 6 1
1
<?php
2
3
namespace Firesphere\GoogleAPI\Extensions;
4
5
use SilverStripe\Forms\DropdownField;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\TextField;
8
use SilverStripe\ORM\DataExtension;
9
10
/**
11
 * Class GoogleAPISiteConfigExtension
12
 *
13
 * @property \SilverStripe\SiteConfig\SiteConfig|\Firesphere\GoogleAPI\Extensions\SiteConfigExtension $owner
14
 * @property string $Viewid
15
 * @property string $DateRange
16
 * @property string $Metric
17
 */
18
class SiteConfigExtension extends DataExtension
19
{
20
    private static $db = [
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...
21
        'Viewid'    => 'Varchar(50)',
22
        'DateRange' => 'Enum("7,30,60,90")',
23
        'Metric' => 'Enum("ga:pageviews")'
24
    ];
25
26
    protected static $date_range = [
27
        7  => '7 Days',
28
        30 => '30 Days',
29
        60 => '60 Days',
30
        90 => '90 Days'
31
    ];
32
33
    protected static $metrics = [
34
        'ga:pageviews' => 'Pageviews',
35
    ];
36
37
    public function updateCMSFields(FieldList $fields)
38
    {
39
        $fields->addFieldsToTab('Root.GoogleAPI', [
40
            TextField::create('Viewid', 'View ID from Analytics'),
0 ignored issues
show
Bug introduced by
'Viewid' of type string is incompatible with the type array expected by parameter $args of SilverStripe\View\ViewableData::create(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
            TextField::create(/** @scrutinizer ignore-type */ 'Viewid', 'View ID from Analytics'),
Loading history...
41
            DropdownField::create('DateRange', 'Amount of days to get', static::$date_range),
42
            DropdownField::create('Metric', 'Metrics', static::$metrics)
43
        ]);
44
    }
45
}
46