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

AquaTheme::ApplyPlot()   C

Complexity

Conditions 9
Paths 9

Size

Total Lines 58
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 30
nc 9
nop 1
dl 0
loc 58
rs 6.9928
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
 * Aqua Theme class
6
 */
7
class AquaTheme extends Theme
8
{
9
    protected $font_color       = '#0044CC';
10
    protected $background_color = '#DDFFFF';
11
    protected $axis_color       = '#0066CC';
12
    protected $grid_color       = '#3366CC';
13
14
    public function GetColorList()
15
    {
16
        return array(
17
            '#183152',
18
            '#C4D7ED',
19
            '#375D81',
20
            '#ABC8E2',
21
            '#E1E6FA',
22
            '#9BBAB2',
23
            '#3B4259',
24
            '#0063BC',
25
            '#1D5A73',
26
            '#ABABFF',
27
            '#27ADC5',
28
            '#EDFFCC',
29
30
/*
1 ignored issue
show
Unused Code Comprehensibility introduced by
66% 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...
31
32
'#66FFFF',
33
'#00AABB',
34
'#00FFCC',
35
'#33CCFF',
36
'#008866',
37
'#99FFFF',
38
'#0099FF',
39
'#99FFCC',
40
'#3399FF',
41
'#2277FF',
42
'#445588',
43
'#003388',
44
'#338877',
45
'#55DDFF',
46
'#00FF99',
47
'#BBBBBB',
48
'#77AAFF',
49
'#00FFCC',
50
 */
51
        );
52
    }
53
54
    public function SetupGraph($graph)
55
    {
56
57
        // graph
58
        /*
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...
59
        $img = $graph->img;
60
        $height = $img->height;
61
        $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25);
62
         */
63
        $graph->SetFrame(false);
64
        $graph->SetMarginColor('white');
65
        $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT);
66
67
        // legend
68
        $graph->legend->SetFrameWeight(0);
69
        $graph->legend->Pos(0.5, 0.85, 'center', 'top');
70
        $graph->legend->SetFillColor('white');
71
        $graph->legend->SetLayout(LEGEND_HOR);
72
        $graph->legend->SetColumns(3);
73
        $graph->legend->SetShadow(false);
74
        $graph->legend->SetMarkAbsSize(5);
75
76
        // xaxis
77
        $graph->xaxis->title->SetColor($this->font_color);
78
        $graph->xaxis->SetColor($this->axis_color, $this->font_color);
79
        $graph->xaxis->SetTickSide(SIDE_BOTTOM);
80
        $graph->xaxis->SetLabelMargin(10);
81
82
        // yaxis
83
        $graph->yaxis->title->SetColor($this->font_color);
84
        $graph->yaxis->SetColor($this->axis_color, $this->font_color);
85
        $graph->yaxis->SetTickSide(SIDE_LEFT);
86
        $graph->yaxis->SetLabelMargin(8);
87
        $graph->yaxis->HideLine();
88
        $graph->yaxis->HideTicks();
89
        $graph->xaxis->SetTitleMargin(15);
90
91
        // grid
92
        $graph->ygrid->SetColor($this->grid_color);
93
        $graph->ygrid->SetLineStyle('dotted');
94
95
        // font
96
        $graph->title->SetColor($this->font_color);
97
        $graph->subtitle->SetColor($this->font_color);
98
        $graph->subsubtitle->SetColor($this->font_color);
99
100
        //        $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...
101
    }
102
103
    public function SetupPieGraph($graph)
104
    {
105
106
        // graph
107
        $graph->SetFrame(false);
108
109
        // legend
110
        $graph->legend->SetFillColor('white');
111
112
        $graph->legend->SetFrameWeight(0);
113
        $graph->legend->Pos(0.5, 0.80, 'center', 'top');
114
        $graph->legend->SetLayout(LEGEND_HOR);
115
        $graph->legend->SetColumns(4);
116
117
        $graph->legend->SetShadow(false);
118
        $graph->legend->SetMarkAbsSize(5);
119
120
        // title
121
        $graph->title->SetColor($this->font_color);
122
        $graph->subtitle->SetColor($this->font_color);
123
        $graph->subsubtitle->SetColor($this->font_color);
124
125
        $graph->SetAntiAliasing();
126
    }
127
128 View Code Duplication
    public function PreStrokeApply($graph)
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...
129
    {
130
        if ($graph->legend->HasItems()) {
131
            $img    = $graph->img;
132
            $height = $img->height;
133
            $graph->SetMargin(
134
                $img->raw_left_margin,
135
                $img->raw_right_margin,
136
                $img->raw_top_margin,
137
                $height * 0.25
138
            );
139
        }
140
    }
141
142
    public function ApplyPlot($plot)
143
    {
144
        switch (get_class($plot)) {
145
            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...
146
                {
147
                    foreach ($plot->plots as $_plot) {
148
                        $this->ApplyPlot($_plot);
149
                    }
150
                    break;
151
                }
152
153
            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...
154
                {
155
                    foreach ($plot->plots as $_plot) {
156
                        $this->ApplyPlot($_plot);
157
                    }
158
                    break;
159
                }
160
161
            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...
162
                {
163
                    $plot->Clear();
164
165
                    $color = $this->GetNextColor();
166
                    $plot->SetColor($color);
167
                    $plot->SetFillColor($color);
168
                    //$plot->SetShadow();
1 ignored issue
show
Unused Code Comprehensibility introduced by
84% 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...
169
                    break;
170
                }
171
172
            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...
173
                {
174
                    $plot->Clear();
175
                    $plot->SetColor($this->GetNextColor());
176
                    $plot->SetWeight(2);
177
                    //                $plot->SetBarCenter();
1 ignored issue
show
Unused Code Comprehensibility introduced by
72% 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...
178
                    break;
179
                }
180
181
            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...
182
                {
183
                    $plot->SetCenter(0.5, 0.45);
184
                    $plot->ShowBorder(false);
185
                    $plot->SetSliceColors($this->GetThemeColors());
186
                    break;
187
                }
188
189
            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...
190
                {
191
                    $plot->SetSliceColors($this->GetThemeColors());
192
                    break;
193
                }
194
195
            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...
196
                {
197
                }
198
        }
199
    }
200
}
201