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

OrangeTheme::SetupPieGraph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 9

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 24
loc 24
rs 8.9713
c 0
b 0
f 0
1
<?php
2
namespace Amenadiel\JpGraph\Themes;
3
4
/**
5
 * Orange Theme class
6
 */
7 View Code Duplication
class OrangeTheme 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       = '#CC4400';
10
    private $background_color = '#FFEEDD';
11
    private $axis_color       = '#CC6600';
12
    private $grid_color       = '#CC6633';
13
14
    public function GetColorList()
15
    {
16
        return array(
17
            '#FF9900',
18
            '#FFCC00',
19
            '#AA6600',
20
            '#CCCC00',
21
            '#CC6600',
22
            '#FFFF66',
23
            '#CCFF00',
24
            '#CC3300',
25
            '#669933',
26
            '#EE7700',
27
            '#AAEE33',
28
            '#77AA00',
29
            '#CCFF99',
30
            '#FF6633',
31
            '#885500',
32
            '#AADD00',
33
            '#99CC44',
34
            '#887711',
35
        );
36
    }
37
38
    public function SetupGraph($graph)
39
    {
40
41
        // graph
42
        /*
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...
43
        $img = $graph->img;
44
        $height = $img->height;
45
        $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25);
46
         */
47
        $graph->SetFrame(false);
48
        $graph->SetMarginColor('white');
49
        $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT);
50
51
        // legend
52
        $graph->legend->SetFrameWeight(0);
53
        $graph->legend->Pos(0.5, 0.85, 'center', 'top');
54
        $graph->legend->SetFillColor('white');
55
        $graph->legend->SetLayout(LEGEND_HOR);
56
        $graph->legend->SetColumns(3);
57
        $graph->legend->SetShadow(false);
58
        $graph->legend->SetMarkAbsSize(5);
59
60
        // xaxis
61
        $graph->xaxis->title->SetColor($this->font_color);
62
        $graph->xaxis->SetColor($this->axis_color, $this->font_color);
63
        $graph->xaxis->SetTickSide(SIDE_BOTTOM);
64
        $graph->xaxis->SetLabelMargin(10);
65
66
        // yaxis
67
        $graph->yaxis->title->SetColor($this->font_color);
68
        $graph->yaxis->SetColor($this->axis_color, $this->font_color);
69
        $graph->yaxis->SetTickSide(SIDE_LEFT);
70
        $graph->yaxis->SetLabelMargin(8);
71
        $graph->yaxis->HideLine();
72
        $graph->yaxis->HideTicks();
73
        $graph->xaxis->SetTitleMargin(15);
74
75
        // grid
76
        $graph->ygrid->SetColor($this->grid_color);
77
        $graph->ygrid->SetLineStyle('dotted');
78
79
        // font
80
        $graph->title->SetColor($this->font_color);
81
        $graph->subtitle->SetColor($this->font_color);
82
        $graph->subsubtitle->SetColor($this->font_color);
83
84
        //        $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...
85
    }
86
87
    public function SetupPieGraph($graph)
88
    {
89
90
        // graph
91
        $graph->SetFrame(false);
92
93
        // legend
94
        $graph->legend->SetFillColor('white');
95
        /*
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...
96
        $graph->legend->SetFrameWeight(0);
97
        $graph->legend->Pos(0.5, 0.85, 'center', 'top');
98
        $graph->legend->SetLayout(LEGEND_HOR);
99
        $graph->legend->SetColumns(3);
100
         */
101
        $graph->legend->SetShadow(false);
102
        $graph->legend->SetMarkAbsSize(5);
103
104
        // title
105
        $graph->title->SetColor($this->font_color);
106
        $graph->subtitle->SetColor($this->font_color);
107
        $graph->subsubtitle->SetColor($this->font_color);
108
109
        $graph->SetAntiAliasing();
110
    }
111
112
    public function PreStrokeApply($graph)
113
    {
114
        if ($graph->legend->HasItems()) {
115
            $img    = $graph->img;
116
            $height = $img->height;
117
            $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25);
118
        }
119
    }
120
121
    public function ApplyPlot($plot)
122
    {
123
        switch (get_class($plot)) {
124
            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...
125
                {
126
                    foreach ($plot->plots as $_plot) {
127
                        $this->ApplyPlot($_plot);
128
                    }
129
                    break;
130
                }
131
132
            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...
133
                {
134
                    foreach ($plot->plots as $_plot) {
135
                        $this->ApplyPlot($_plot);
136
                    }
137
                    break;
138
                }
139
140
            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...
141
                {
142
                    $plot->Clear();
143
144
                    $color = $this->GetNextColor();
145
                    $plot->SetColor($color);
146
                    $plot->SetFillColor($color);
147
                    $plot->SetShadow('red', 3, 4, false);
148
                    break;
149
                }
150
151
            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...
152
                {
153
                    $plot->Clear();
154
155
                    $plot->SetColor($this->GetNextColor() . '@0.4');
156
                    $plot->SetWeight(2);
157
                    break;
158
                }
159
160
            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...
161
                {
162
                    $plot->ShowBorder(false);
163
                    $plot->SetSliceColors($this->GetThemeColors());
164
                    break;
165
                }
166
167
            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...
168
                {
169
                    $plot->SetSliceColors($this->GetThemeColors());
170
                    break;
171
                }
172
173
            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...
174
                {
175
                }
176
        }
177
    }
178
}
179