Completed
Pull Request — develop (#190)
by Franck
08:58
created

AbstractType::setSeries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * This file is part of PHPPresentation - A pure PHP library for reading and writing
4
 * presentations documents.
5
 *
6
 * PHPPresentation is free software distributed under the terms of the GNU Lesser
7
 * General Public License version 3 as published by the Free Software Foundation.
8
 *
9
 * For the full copyright and license information, please read the LICENSE
10
 * file that was distributed with this source code. For the full list of
11
 * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12
 *
13
 * @link        https://github.com/PHPOffice/PHPPresentation
14
 * @copyright   2009-2015 PHPPresentation contributors
15
 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16
 */
17
18
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
19
20
use PhpOffice\PhpPresentation\ComparableInterface;
21
use PhpOffice\PhpPresentation\Shape\Chart\Series;
22
23
/**
24
 * \PhpOffice\PhpPresentation\Shape\Chart\Type
25
 */
26
abstract class AbstractType implements ComparableInterface
27
{
28
    /**
29
     * Has Axis X?
30
     *
31
     * @var boolean
32
     */
33
    protected $hasAxisX = true;
34
35
    /**
36
     * Has Axis Y?
37
     *
38
     * @var boolean
39
     */
40
    protected $hasAxisY = true;
41
42
    /**
43
     * Hash index
44
     *
45
     * @var string
46
     */
47
    private $hashIndex;
48
    
49
    /**
50
     * Data
51
     *
52
     * @var array
53
     */
54
    private $data = array();
55
56
    /**
57
     * Has Axis X?
58
     *
59
     * @return boolean
60
     */
61 24
    public function hasAxisX()
62
    {
63 24
        return $this->hasAxisX;
64
    }
65
66
    /**
67
     * Has Axis Y?
68
     *
69
     * @return boolean
70
     */
71 24
    public function hasAxisY()
72
    {
73 24
        return $this->hasAxisY;
74
    }
75
76
    /**
77
     * Get hash index
78
     *
79
     * Note that this index may vary during script execution! Only reliable moment is
80
     * while doing a write of a workbook and when changes are not allowed.
81
     *
82
     * @return string Hash index
83
     */
84 1
    public function getHashIndex()
85
    {
86 1
        return $this->hashIndex;
87
    }
88
89
    /**
90
     * Set hash index
91
     *
92
     * Note that this index may vary during script execution! Only reliable moment is
93
     * while doing a write of a workbook and when changes are not allowed.
94
     *
95
     * @param string $value Hash index
96
     */
97 1
    public function setHashIndex($value)
98
    {
99 1
        $this->hashIndex = $value;
100 1
        return $this;
101
    }
102
103
    /**
104
     * Add Series
105
     *
106
     * @param  \PhpOffice\PhpPresentation\Shape\Chart\Series $value
107
     * @return self
108
     */
109 52
    public function addSeries(Series $value)
110
    {
111 52
        $this->data[] = $value;
112 52
        return $this;
113
    }
114
115
    /**
116
     * Get Series
117
     *
118
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series[]
119
     */
120 62
    public function getSeries()
121
    {
122 62
        return $this->data;
123
    }
124
125
    /**
126
     * Set Series
127
     *
128
     * @param  array $value Array of \PhpOffice\PhpPresentation\Shape\Chart\Series
129
     * @return self
130
     */
131 15
    public function setSeries($value = array())
132
    {
133 15
        $this->data = $value;
134 15
        return $this;
135
    }
136
137
    /**
138
     * Get Data
139
     *
140
     * @deprecated getSeries
141
     */
142 18
    public function getData()
143
    {
144 18
        return $this->getSeries();
145
    }
146
147
    /**
148
     * Set Data
149
     *
150
     * @deprecated setSeries
151
     */
152
    public function setData($value = array())
153
    {
154
        return $this->setSeries($value);
155
    }
156
157
    /**
158
     * @return mixed
159
     * @link http://php.net/manual/en/language.oop5.cloning.php
160
     */
161
    public function __clone()
162
    {
163
        $arrayClone = array();
164
        foreach ($this->data as $itemSeries) {
165
            $arrayClone[] = clone $itemSeries;
166
        }
167
        $this->data = $arrayClone;
168
    }
169
}
170