Passed
Push — master ( 8f5e6a...061d3e )
by Felipe
03:26
created

GreenTheme::ApplyPlot()   B

Complexity

Conditions 9
Paths 9

Size

Total Lines 57
Code Lines 30

Duplication

Lines 57
Ratio 100 %

Importance

Changes 0
Metric Value
cc 9
eloc 30
nc 9
nop 1
dl 57
loc 57
rs 7.0745
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace Amenadiel\JpGraph\Themes;
3
4
/**
5
 * Green Theme class
6
 */
7 View Code Duplication
class GreenTheme extends Theme
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...
8
{
9
    private $font_color       = '#009900';
10
    private $background_color = '#EEFFDD';
11
    private $axis_color       = '#00CC00';
12
    private $grid_color       = '#33CC33';
13
14
    public function GetColorList()
15
    {
16
        return array(
17
            '#66CC00',
18
            '#009900',
19
            '#AAFF77',
20
            '#559922',
21
            '#00CC33',
22
            '#99FF00',
23
            '#009966',
24
            '#00FF99',
25
            '#99BB66',
26
            '#33FF00',
27
            '#DDFFBB',
28
            '#669933',
29
            '#BBDDCC',
30
            '#77CCBB',
31
            '#668833',
32
            '#BBEE66',
33
        );
34
    }
35
36
    public function SetupGraph($graph)
37
    {
38
39
        // graph
40
        /*
1 ignored issue
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
        $img = $graph->img;
42
        $height = $img->height;
43
        $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25);
44
         */
45
        $graph->SetFrame(false);
46
        $graph->SetMarginColor('white');
47
        $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT);
48
49
        // legend
50
        $graph->legend->SetFrameWeight(0);
51
        $graph->legend->Pos(0.5, 0.85, 'center', 'top');
52
        $graph->legend->SetFillColor('white');
53
        $graph->legend->SetLayout(LEGEND_HOR);
54
        $graph->legend->SetColumns(3);
55
        $graph->legend->SetShadow(false);
56
        $graph->legend->SetMarkAbsSize(5);
57
58
        // xaxis
59
        $graph->xaxis->title->SetColor($this->font_color);
60
        $graph->xaxis->SetColor($this->axis_color, $this->font_color);
61
        $graph->xaxis->SetTickSide(SIDE_BOTTOM);
62
        $graph->xaxis->SetLabelMargin(10);
63
64
        // yaxis
65
        $graph->yaxis->title->SetColor($this->font_color);
66
        $graph->yaxis->SetColor($this->axis_color, $this->font_color);
67
        $graph->yaxis->SetTickSide(SIDE_LEFT);
68
        $graph->yaxis->SetLabelMargin(8);
69
        $graph->yaxis->HideLine();
70
        $graph->yaxis->HideTicks();
71
        $graph->xaxis->SetTitleMargin(15);
72
73
        // grid
74
        $graph->ygrid->SetColor($this->grid_color);
75
        $graph->ygrid->SetLineStyle('dotted');
76
77
        // font
78
        $graph->title->SetColor($this->font_color);
79
        $graph->subtitle->SetColor($this->font_color);
80
        $graph->subsubtitle->SetColor($this->font_color);
81
82
        //        $graph->img->SetAntiAliasing();
1 ignored issue
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
83
    }
84
85
    public function SetupPieGraph($graph)
86
    {
87
88
        // graph
89
        $graph->SetFrame(false);
90
91
        // legend
92
        $graph->legend->SetFillColor('white');
93
        /*
1 ignored issue
show
Unused Code Comprehensibility introduced by
68% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
94
        $graph->legend->SetFrameWeight(0);
95
        $graph->legend->Pos(0.5, 0.85, 'center', 'top');
96
        $graph->legend->SetLayout(LEGEND_HOR);
97
        $graph->legend->SetColumns(3);
98
         */
99
        $graph->legend->SetShadow(false);
100
        $graph->legend->SetMarkAbsSize(5);
101
102
        // title
103
        $graph->title->SetColor($this->font_color);
104
        $graph->subtitle->SetColor($this->font_color);
105
        $graph->subsubtitle->SetColor($this->font_color);
106
107
        $graph->SetAntiAliasing();
108
    }
109
110
    public function PreStrokeApply($graph)
111
    {
112
        if ($graph->legend->HasItems()) {
113
            $img    = $graph->img;
114
            $height = $img->height;
115
            $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25);
116
        }
117
    }
118
119
    public function ApplyPlot($plot)
120
    {
121
        switch (get_class($plot)) {
122
            case 'GroupBarPlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
123
                {
124
                    foreach ($plot->plots as $_plot) {
125
                        $this->ApplyPlot($_plot);
126
                    }
127
                    break;
128
                }
129
130
            case 'AccBarPlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
131
                {
132
                    foreach ($plot->plots as $_plot) {
133
                        $this->ApplyPlot($_plot);
134
                    }
135
                    break;
136
                }
137
138
            case 'BarPlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
139
                {
140
                    $plot->Clear();
141
142
                    $color = $this->GetNextColor();
143
                    $plot->SetColor($color);
144
                    $plot->SetFillColor($color);
145
                    $plot->SetShadow('red', 3, 4, false);
146
                    break;
147
                }
148
149
            case 'LinePlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
150
                {
151
                    $plot->Clear();
152
153
                    $plot->SetColor($this->GetNextColor() . '@0.4');
154
                    $plot->SetWeight(2);
155
                    break;
156
                }
157
158
            case 'PiePlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
159
                {
160
                    $plot->ShowBorder(false);
161
                    $plot->SetSliceColors($this->GetThemeColors());
162
                    break;
163
                }
164
165
            case 'PiePlot3D':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
166
                {
167
                    $plot->SetSliceColors($this->GetThemeColors());
168
                    break;
169
                }
170
171
            default:
0 ignored issues
show
Coding Style introduced by
DEFAULT statements must be defined using a colon

As per the PSR-2 coding standard, default statements should not be wrapped in curly braces.

switch ($expr) {
    default: { //wrong
        doSomething();
        break;
    }
}

switch ($expr) {
    default: //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
172
                {
173
                }
174
        }
175
    }
176
}
177