StockistsCountryReports_WithoutCountry   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 67
loc 67
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A title() 4 4 1
A group() 4 4 1
A sort() 4 4 1
A sourceRecords() 4 4 1
A columns() 9 9 1
A getParameterFields() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 *
5
 * @authors: Nicolaas [at] Sunny Side Up .co.nz
6
 * @sub-package: reports
7
 * @inspiration: Silverstripe Ltd, Jeremy
8
 **/
9
10 View Code Duplication
class StockistsCountryReports_WithoutCountry extends SS_Report
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
13
    /**
14
     * The class of object being managed by this report.
15
     * Set by overriding in your subclass.
16
     */
17
    protected $dataClass = 'StockistCountryPage';
18
19
    /**
20
     *
21
     * @return String
22
     */
23
    public function title()
24
    {
25
        return "STOCKISTS: stockist countries without a country (".$this->sourceRecords()->count().")";
26
    }
27
28
    /**
29
     * not sure if this is used in SS3
30
     * @return String
31
     */
32
    public function group()
33
    {
34
        return "Stockists";
35
    }
36
37
    /**
38
     *
39
     * @return INT - for sorting reports
40
     */
41
    public function sort()
42
    {
43
        return 9000;
44
    }
45
46
    /**
47
     * working out the items
48
     * @return DataList
49
     */
50
    public function sourceRecords($params = null)
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
    {
52
        return StockistCountryPage::get()->where("Country = '' OR Country IS NULL");
53
    }
54
55
    /**
56
     * @return Array
57
     */
58
    public function columns()
59
    {
60
        return array(
61
            "Title" => array(
62
                "title" => "FullName",
63
                "link" => true
64
            )
65
        );
66
    }
67
68
    /**
69
     *
70
     * @return FieldList
71
     */
72
    public function getParameterFields()
73
    {
74
        return new FieldList();
75
    }
76
}
77