Completed
Pull Request — develop (#339)
by Franck
07:38
created

Axis::setHashIndex()   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

Importance

Changes 0
Metric Value
c 0
b 0
f 0
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;
19
20
use PhpOffice\PhpPresentation\ComparableInterface;
21
use PhpOffice\PhpPresentation\Style\Font;
22
23
/**
24
 * \PhpOffice\PhpPresentation\Shape\Chart\Axis
25
 */
26
class Axis implements ComparableInterface
27
{
28
    const AXIS_X = 'x';
29
    const AXIS_Y = 'y';
30
31
    const TICK_MARK_NONE = 'none';
32
    const TICK_MARK_CROSS = 'cross';
33
    const TICK_MARK_INSIDE = 'in';
34
    const TICK_MARK_OUTSIDE = 'out';
35
36
    /**
37
     * Title
38
     *
39
     * @var string
40
     */
41
    private $title = 'Axis Title';
42
43
    /**
44
     * Format code
45
     *
46
     * @var string
47
     */
48
    private $formatCode = '';
49
50
    /**
51
     * Font
52
     *
53
     * @var \PhpOffice\PhpPresentation\Style\Font
54
     */
55
    private $font;
56
57
    /**
58
     * @var Gridlines
59
     */
60
    protected $majorGridlines;
61
62
    /**
63
     * @var Gridlines
64
     */
65
    protected $minorGridlines;
66
67
    /**
68
     * @var int
69
     */
70
    protected $minBounds;
71
72
    /**
73
     * @var int
74
     */
75
    protected $maxBounds;
76
77
    /**
78
     * @var string
79
     */
80
    protected $minorTickMark = self::TICK_MARK_NONE;
81
82
    /**
83
     * @var string
84
     */
85
    protected $majorTickMark = self::TICK_MARK_NONE;
86
87
    /**
88
     * @var float
89
     */
90
    protected $minorUnit;
91
92
    /**
93
     * @var float
94
     */
95
    protected $majorUnit;
96
97
    /**
98
     * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
99
     *
100
     * @param string $title Title
101
     */
102 73
    public function __construct($title = 'Axis Title')
103
    {
104 73
        $this->title = $title;
105 73
        $this->font  = new Font();
106 73
    }
107
108
    /**
109
     * Get Title
110
     *
111
     * @return string
112
     */
113 25
    public function getTitle()
114
    {
115 25
        return $this->title;
116
    }
117
118
    /**
119
     * Set Title
120
     *
121
     * @param  string                         $value
122
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
123
     */
124 1
    public function setTitle($value = 'Axis Title')
125
    {
126 1
        $this->title = $value;
127
128 1
        return $this;
129
    }
130
131
    /**
132
     * Get font
133
     *
134
     * @return \PhpOffice\PhpPresentation\Style\Font
135
     */
136 48
    public function getFont()
137
    {
138 48
        return $this->font;
139
    }
140
141
    /**
142
     * Set font
143
     *
144
     * @param  \PhpOffice\PhpPresentation\Style\Font               $pFont Font
145
     * @throws \Exception
146
     * @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
147
     */
148 1
    public function setFont(Font $pFont = null)
149
    {
150 1
        $this->font = $pFont;
151 1
        return $this;
152
    }
153
154
    /**
155
     * Get Format Code
156
     *
157
     * @return string
158
     */
159 24
    public function getFormatCode()
160
    {
161 24
        return $this->formatCode;
162
    }
163
164
    /**
165
     * Set Format Code
166
     *
167
     * @param  string                         $value
168
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
169
     */
170 1
    public function setFormatCode($value = '')
171
    {
172 1
        $this->formatCode = $value;
173
174 1
        return $this;
175
    }
176
177
    /**
178
     * @return int|null
179
     */
180 47
    public function getMinBounds()
181
    {
182 47
        return $this->minBounds;
183
    }
184
185
    /**
186
     * @param int|null $minBounds
187
     * @return Axis
188
     */
189 3
    public function setMinBounds($minBounds = null)
190
    {
191 3
        $this->minBounds = is_null($minBounds) ? null : (int)$minBounds;
192 3
        return $this;
193
    }
194
195
    /**
196
     * @return int|null
197
     */
198 47
    public function getMaxBounds()
199
    {
200 47
        return $this->maxBounds;
201
    }
202
203
    /**
204
     * @param int|null $maxBounds
205
     * @return Axis
206
     */
207 3
    public function setMaxBounds($maxBounds = null)
208
    {
209 3
        $this->maxBounds = is_null($maxBounds) ? null : (int)$maxBounds;
210 3
        return $this;
211
    }
212
213
    /**
214
     * @return Gridlines
215
     */
216 48
    public function getMajorGridlines()
217
    {
218 48
        return $this->majorGridlines;
219
    }
220
221
    /**
222
     * @param Gridlines $majorGridlines
223
     * @return Axis
224
     */
225 3
    public function setMajorGridlines(Gridlines $majorGridlines)
226
    {
227 3
        $this->majorGridlines = $majorGridlines;
228 3
        return $this;
229
    }
230
231
    /**
232
     * @return Gridlines
233
     */
234 48
    public function getMinorGridlines()
235
    {
236 48
        return $this->minorGridlines;
237
    }
238
239
    /**
240
     * @param Gridlines $minorGridlines
241
     * @return Axis
242
     */
243 3
    public function setMinorGridlines(Gridlines $minorGridlines)
244
    {
245 3
        $this->minorGridlines = $minorGridlines;
246 3
        return $this;
247
    }
248
249
    /**
250
     * @return string
251
     */
252 24
    public function getMinorTickMark()
253
    {
254 24
        return $this->minorTickMark;
255
    }
256
257
    /**
258
     * @param string $pTickMark
259
     * @return Axis
260
     */
261 2
    public function setMinorTickMark($pTickMark = self::TICK_MARK_NONE)
262
    {
263 2
        $this->minorTickMark = $pTickMark;
264 2
        return $this;
265
    }
266
267
    /**
268
     * @return string
269
     */
270 24
    public function getMajorTickMark()
271
    {
272 24
        return $this->majorTickMark;
273
    }
274
275
    /**
276
     * @param string $pTickMark
277
     * @return Axis
278
     */
279 2
    public function setMajorTickMark($pTickMark = self::TICK_MARK_NONE)
280
    {
281 2
        $this->majorTickMark = $pTickMark;
282 2
        return $this;
283
    }
284
285
    /**
286
     * @return float
287
     */
288 24
    public function getMinorUnit()
289
    {
290 24
        return $this->minorUnit;
291
    }
292
293
    /**
294
     * @param float $pUnit
295
     * @return Axis
296
     */
297 2
    public function setMinorUnit($pUnit = null)
298
    {
299 2
        $this->minorUnit = $pUnit;
300 2
        return $this;
301
    }
302
303
    /**
304
     * @return float
305
     */
306 24
    public function getMajorUnit()
307
    {
308 24
        return $this->majorUnit;
309
    }
310
311
    /**
312
     * @param float $pUnit
313
     * @return Axis
314
     */
315 2
    public function setMajorUnit($pUnit = null)
316
    {
317 2
        $this->majorUnit = $pUnit;
318 2
        return $this;
319
    }
320
321
    /**
322
     * Get hash code
323
     *
324
     * @return string Hash code
325
     */
326 52
    public function getHashCode()
327
    {
328 52
        return md5($this->title . $this->formatCode . __CLASS__);
329
    }
330
331
    /**
332
     * Hash index
333
     *
334
     * @var string
335
     */
336
    private $hashIndex;
337
338
    /**
339
     * Get hash index
340
     *
341
     * Note that this index may vary during script execution! Only reliable moment is
342
     * while doing a write of a workbook and when changes are not allowed.
343
     *
344
     * @return string Hash index
345
     */
346 1
    public function getHashIndex()
347
    {
348 1
        return $this->hashIndex;
349
    }
350
351
    /**
352
     * Set hash index
353
     *
354
     * Note that this index may vary during script execution! Only reliable moment is
355
     * while doing a write of a workbook and when changes are not allowed.
356
     *
357
     * @param string $value Hash index
358
     */
359 1
    public function setHashIndex($value)
360
    {
361 1
        $this->hashIndex = $value;
362 1
        return $this;
363
    }
364
}
365