StockistsReport_WithoutAPicture   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 StockistsReport_WithoutAPicture 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 = 'StockistPage';
18
19
    /**
20
     *
21
     * @return String
22
     */
23
    public function title()
24
    {
25
        return "STOCKISTS: without a picture (".$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 StockistPage::get()->filter(array("ImageID" => 0));
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
78 View Code Duplication
class StockistsReport_WithoutALogo 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...
79
{
80
81
    /**
82
     * The class of object being managed by this report.
83
     * Set by overriding in your subclass.
84
     */
85
    protected $dataClass = 'StockistPage';
86
87
    /**
88
     *
89
     * @return String
90
     */
91
    public function title()
92
    {
93
        return "STOCKISTS: without a logo (".$this->sourceRecords()->count().")";
94
    }
95
96
    /**
97
     * not sure if this is used in SS3
98
     * @return String
99
     */
100
    public function group()
101
    {
102
        return "Stockists";
103
    }
104
105
    /**
106
     *
107
     * @return INT - for sorting reports
108
     */
109
    public function sort()
110
    {
111
        return 9000;
112
    }
113
114
    /**
115
     * working out the items
116
     * @return DataList
117
     */
118
    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...
119
    {
120
        return StockistPage::get()->filter(array("LogoID" => 0));
121
    }
122
123
    /**
124
     * @return Array
125
     */
126
    public function columns()
127
    {
128
        return array(
129
            "Title" => array(
130
                "title" => "FullName",
131
                "link" => true
132
            )
133
        );
134
    }
135
136
    /**
137
     *
138
     * @return FieldList
139
     */
140
    public function getParameterFields()
141
    {
142
        return new FieldList();
143
    }
144
}
145
146
class StockistsReport_WithoutAnAddress extends SS_Report
147
{
148
149
    /**
150
     * The class of object being managed by this report.
151
     * Set by overriding in your subclass.
152
     */
153
    protected $dataClass = 'StockistPage';
154
155
    /**
156
     *
157
     * @return String
158
     */
159
    public function title()
160
    {
161
        return "STOCKISTS: without an address (".$this->sourceRecords()->count().")";
162
    }
163
164
    /**
165
     * not sure if this is used in SS3
166
     * @return String
167
     */
168
    public function group()
169
    {
170
        return "Stockists";
171
    }
172
173
    /**
174
     *
175
     * @return INT - for sorting reports
176
     */
177
    public function sort()
178
    {
179
        return 9000;
180
    }
181
182
    /**
183
     * working out the items
184
     * @return DataList
185
     */
186
    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...
187
    {
188
        $stage = '';
189
        if (Versioned::current_stage() == 'Live') {
190
            $stage = '_Live';
191
        }
192
        return StockistPage::get()->where("GoogleMapLocationsObject.ID IS NULL OR HasGeoInfo = 0")
193
            ->leftJoin("GoogleMapLocationsObject", "GoogleMapLocationsObject.ParentID = StockistPage".$stage.".ID");
194
    }
195
196
    /**
197
     * @return Array
198
     */
199
    public function columns()
200
    {
201
        return array(
202
            "Title" => array(
203
                "title" => "FullName",
204
                "link" => true
205
            )
206
        );
207
    }
208
209
    /**
210
     *
211
     * @return FieldList
212
     */
213
    public function getParameterFields()
214
    {
215
        return new FieldList();
216
    }
217
}
218
219
220 View Code Duplication
class StockistsReport_OnlineStockists 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...
221
{
222
223
    /**
224
     * The class of object being managed by this report.
225
     * Set by overriding in your subclass.
226
     */
227
    protected $dataClass = 'StockistPage';
228
229
    /**
230
     *
231
     * @return String
232
     */
233
    public function title()
234
    {
235
        return "STOCKISTS: has online store (".$this->sourceRecords()->count().")";
236
    }
237
238
    /**
239
     * not sure if this is used in SS3
240
     * @return String
241
     */
242
    public function group()
243
    {
244
        return "Stockists";
245
    }
246
247
    /**
248
     *
249
     * @return INT - for sorting reports
250
     */
251
    public function sort()
252
    {
253
        return 9000;
254
    }
255
256
    /**
257
     * working out the items
258
     * @return DataList
259
     */
260
    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...
261
    {
262
        return StockistPage::get()->filter(array("HasWebStore" => 1));
263
    }
264
265
    /**
266
     * @return Array
267
     */
268
    public function columns()
269
    {
270
        return array(
271
            "Title" => array(
272
                "title" => "FullName",
273
                "link" => true
274
            )
275
        );
276
    }
277
278
    /**
279
     *
280
     * @return FieldList
281
     */
282
    public function getParameterFields()
283
    {
284
        return new FieldList();
285
    }
286
}
287