PercentDataType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 28.21 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 11
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultFilterMethod() 0 4 1
A getName() 0 4 1
A getAvailableFilterMethods() 11 11 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
namespace Netdudes\DataSourceryBundle\DataType;
3
4
use Netdudes\DataSourceryBundle\Query\FilterCondition;
5
6
class PercentDataType extends AbstractDataType
7
{
8
    /**
9
     * Return the identifier of the default sort method.
10
     *
11
     * @return int
12
     */
13
    public function getDefaultFilterMethod()
14
    {
15
        return FilterCondition::METHOD_NUMERIC_EQ;
16
    }
17
18
    /**
19
     * Return the name of the type, unique.
20
     *
21
     * @return string
22
     */
23
    public function getName()
24
    {
25
        return 'percentage';
26
    }
27
28
    /**
29
     * Return an array of available sorting methods.
30
     *
31
     * @return array
32
     */
33 View Code Duplication
    public function getAvailableFilterMethods()
0 ignored issues
show
Duplication introduced by
This method 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...
34
    {
35
        return [
36
            FilterCondition::METHOD_NUMERIC_GT,
37
            FilterCondition::METHOD_NUMERIC_GTE,
38
            FilterCondition::METHOD_NUMERIC_EQ,
39
            FilterCondition::METHOD_NUMERIC_LTE,
40
            FilterCondition::METHOD_NUMERIC_LT,
41
            FilterCondition::METHOD_NUMERIC_NEQ,
42
        ];
43
    }
44
}
45