Completed
Pull Request — develop (#362)
by Franck
02:56
created

Axis::isVisible()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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