Completed
Push — develop ( c96e2d...d2f55f )
by Adrien
48:43 queued 44:11
created

PlotArea   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Test Coverage

Coverage 56.52%

Importance

Changes 0
Metric Value
dl 0
loc 103
ccs 13
cts 23
cp 0.5652
rs 10
c 0
b 0
f 0
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getPlotGroup() 0 3 1
A getPlotSeriesCount() 0 8 2
A getPlotGroupByIndex() 0 3 1
A __construct() 0 4 1
A getLayout() 0 3 1
A getPlotGroupCount() 0 3 1
A setPlotSeries() 0 5 1
A refresh() 0 4 2
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Chart;
4
5
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
6
7
class PlotArea
8
{
9
    /**
10
     * PlotArea Layout.
11
     *
12
     * @var Layout
13
     */
14
    private $layout;
15
16
    /**
17
     * Plot Series.
18
     *
19
     * @var DataSeries[]
20
     */
21
    private $plotSeries = [];
22
23
    /**
24
     * Create a new PlotArea.
25
     *
26
     * @param null|Layout $layout
27
     * @param DataSeries[] $plotSeries
28
     */
29 15
    public function __construct(Layout $layout = null, array $plotSeries = [])
30
    {
31 15
        $this->layout = $layout;
32 15
        $this->plotSeries = $plotSeries;
33 15
    }
34
35
    /**
36
     * Get Layout.
37
     *
38
     * @return Layout
39
     */
40 13
    public function getLayout()
41
    {
42 13
        return $this->layout;
43
    }
44
45
    /**
46
     * Get Number of Plot Groups.
47
     *
48
     * @return array of DataSeries
49
     */
50 14
    public function getPlotGroupCount()
51
    {
52 14
        return count($this->plotSeries);
0 ignored issues
show
Bug Best Practice introduced by
The expression return count($this->plotSeries) returns the type integer which is incompatible with the documented return type array.
Loading history...
53
    }
54
55
    /**
56
     * Get Number of Plot Series.
57
     *
58
     * @return int
59
     */
60
    public function getPlotSeriesCount()
61
    {
62
        $seriesCount = 0;
63
        foreach ($this->plotSeries as $plot) {
64
            $seriesCount += $plot->getPlotSeriesCount();
65
        }
66
67
        return $seriesCount;
68
    }
69
70
    /**
71
     * Get Plot Series.
72
     *
73
     * @return array of DataSeries
74
     */
75
    public function getPlotGroup()
76
    {
77
        return $this->plotSeries;
78
    }
79
80
    /**
81
     * Get Plot Series by Index.
82
     *
83
     * @param mixed $index
84
     *
85
     * @return DataSeries
86
     */
87 14
    public function getPlotGroupByIndex($index)
88
    {
89 14
        return $this->plotSeries[$index];
90
    }
91
92
    /**
93
     * Set Plot Series.
94
     *
95
     * @param DataSeries[] $plotSeries
96
     *
97
     * @return PlotArea
98
     */
99
    public function setPlotSeries(array $plotSeries)
100
    {
101
        $this->plotSeries = $plotSeries;
102
103
        return $this;
104
    }
105
106 14
    public function refresh(Worksheet $worksheet)
107
    {
108 14
        foreach ($this->plotSeries as $plotSeries) {
109 14
            $plotSeries->refresh($worksheet);
110
        }
111 14
    }
112
}
113