Test Failed
Pull Request — master (#144)
by
unknown
05:06
created

ErrorLinePlot::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 9
ccs 0
cts 8
cp 0
crap 6
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * JPGraph v4.0.3
5
 */
6
7
namespace Amenadiel\JpGraph\Plot;
8
9
/**
10
 * @class ErrorLinePlot
11
 * // Description: Combine a line and error plot
12
 * // THIS IS A DEPRECATED PLOT TYPE JUST KEPT FOR
13
 * // BACKWARD COMPATIBILITY
14
 */
15
class ErrorLinePlot extends ErrorPlot
16
{
17
    public $line;
18
19
    /**
20
     * CONSTRUCTOR.
21
     *
22
     * @param mixed $datay
23
     * @param mixed $datax
24
     */
25
    public function __construct($datay, $datax = false)
26
    {
27
        parent::__construct($datay, $datax);
28
        // Calculate line coordinates as the average of the error limits
29
        $n = safe_count($datay);
30
        for ($i = 0; $i < $n; $i += 2) {
31
            $ly[] = ($datay[$i] + $datay[$i + 1]) / 2;
32
        }
33
        $this->line = new LinePlot($ly, $datax);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ly does not seem to be defined for all execution paths leading up to this point.
Loading history...
34
    }
35
36
    /**
37
     * PUBLIC METHODS.
38
     *
39
     * @param mixed $graph
40
     */
41
    public function Legend($graph)
42
    {
43
        if ($this->legend != '') {
44
            $graph->legend->Add($this->legend, $this->color);
45
        }
46
47
        $this->line->Legend($graph);
48
    }
49
50
    public function Stroke($img, $xscale, $yscale)
51
    {
52
        parent::Stroke($img, $xscale, $yscale);
53
        $this->line->Stroke($img, $xscale, $yscale);
54
    }
55
} // @class
56