Completed
Pull Request — develop (#435)
by Franck
15:48 queued 42s
created

Axis::setCrossesAt()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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
    protected $crossesAt=0;
110
111
    /**
112
     * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
113
     *
114
     * @param string $title Title
115
     */
116 80
    public function __construct($title = 'Axis Title')
117
    {
118 80
        $this->title = $title;
119 80
        $this->outline = new Outline();
120 80
        $this->font  = new Font();
121 80
    }
122
123
    /**
124
     * Get Title
125
     *
126
     * @return string
127
     */
128 30
    public function getTitle()
129
    {
130 30
        return $this->title;
131
    }
132
133
    /**
134
     * Set Title
135
     *
136
     * @param  string                         $value
137
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
138
     */
139 1
    public function setTitle($value = 'Axis Title')
140
    {
141 1
        $this->title = $value;
142
143 1
        return $this;
144
    }
145
146
    /**
147
     * Get font
148
     *
149
     * @return \PhpOffice\PhpPresentation\Style\Font
150
     */
151 54
    public function getFont()
152
    {
153 54
        return $this->font;
154
    }
155
156
157
158
    /**
159
     * Set crossesAt
160
     *
161
     * @param  int                         $value
162
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
163
     */
164
    public function setCrossesAt($value = null)
165
    {
166
        $this->crossesAt = is_null($value) ? null : (int)$value;
167
        return $this;
168
    }
169
170
    /**
171
     * Get font
172
     *
173
     * @return int
174
     */
175 5
    public function getCrossesAt()
176
    {
177 5
        return $this->crossesAt;
178
    }
179
180
181
182
    /**
183
     * Set font
184
     *
185
     * @param  \PhpOffice\PhpPresentation\Style\Font               $pFont Font
186
     * @throws \Exception
187
     * @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
188
     */
189 1
    public function setFont(Font $pFont = null)
190
    {
191 1
        $this->font = $pFont;
192 1
        return $this;
193
    }
194
195
    /**
196
     * Get Format Code
197
     *
198
     * @return string
199
     */
200 1
    public function getFormatCode()
201
    {
202 1
        return $this->formatCode;
203
    }
204
205
    /**
206
     * Set Format Code
207
     *
208
     * @param  string                         $value
209
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
210
     */
211 1
    public function setFormatCode($value = '')
212
    {
213 1
        $this->formatCode = $value;
214
215 1
        return $this;
216
    }
217
218
    /**
219
     * @return int|null
220
     */
221 53
    public function getMinBounds()
222
    {
223 53
        return $this->minBounds;
224
    }
225
226
    /**
227
     * @param int|null $minBounds
228
     * @return Axis
229
     */
230 3
    public function setMinBounds($minBounds = null)
231
    {
232 3
        $this->minBounds = is_null($minBounds) ? null : (int)$minBounds;
233 3
        return $this;
234
    }
235
236
    /**
237
     * @return int|null
238
     */
239 53
    public function getMaxBounds()
240
    {
241 53
        return $this->maxBounds;
242
    }
243
244
    /**
245
     * @param int|null $maxBounds
246
     * @return Axis
247
     */
248 2
    public function setMaxBounds($maxBounds = null)
249
    {
250 2
        $this->maxBounds = is_null($maxBounds) ? null : (int)$maxBounds;
251 2
        return $this;
252
    }
253
254
    /**
255
     * @return Gridlines
256
     */
257 54
    public function getMajorGridlines()
258
    {
259 54
        return $this->majorGridlines;
260
    }
261
262
    /**
263
     * @param Gridlines $majorGridlines
264
     * @return Axis
265
     */
266 3
    public function setMajorGridlines(Gridlines $majorGridlines)
267
    {
268 3
        $this->majorGridlines = $majorGridlines;
269 3
        return $this;
270
    }
271
272
    /**
273
     * @return Gridlines
274
     */
275 54
    public function getMinorGridlines()
276
    {
277 54
        return $this->minorGridlines;
278
    }
279
280
    /**
281
     * @param Gridlines $minorGridlines
282
     * @return Axis
283
     */
284 2
    public function setMinorGridlines(Gridlines $minorGridlines)
285
    {
286 2
        $this->minorGridlines = $minorGridlines;
287 2
        return $this;
288
    }
289
290
    /**
291
     * @return string
292
     */
293 29
    public function getMinorTickMark()
294
    {
295 29
        return $this->minorTickMark;
296
    }
297
298
    /**
299
     * @param string $pTickMark
300
     * @return Axis
301
     */
302 2
    public function setMinorTickMark($pTickMark = self::TICK_MARK_NONE)
303
    {
304 2
        $this->minorTickMark = $pTickMark;
305 2
        return $this;
306
    }
307
308
    /**
309
     * @return string
310
     */
311 29
    public function getMajorTickMark()
312
    {
313 29
        return $this->majorTickMark;
314
    }
315
316
    /**
317
     * @param string $pTickMark
318
     * @return Axis
319
     */
320 1
    public function setMajorTickMark($pTickMark = self::TICK_MARK_NONE)
321
    {
322 1
        $this->majorTickMark = $pTickMark;
323 1
        return $this;
324
    }
325
326
    /**
327
     * @return float
328
     */
329 29
    public function getMinorUnit()
330
    {
331 29
        return $this->minorUnit;
332
    }
333
334
    /**
335
     * @param float $pUnit
336
     * @return Axis
337
     */
338 2
    public function setMinorUnit($pUnit = null)
339
    {
340 2
        $this->minorUnit = $pUnit;
341 2
        return $this;
342
    }
343
344
    /**
345
     * @return float
346
     */
347 29
    public function getMajorUnit()
348
    {
349 29
        return $this->majorUnit;
350
    }
351
352
    /**
353
     * @param float $pUnit
354
     * @return Axis
355
     */
356 2
    public function setMajorUnit($pUnit = null)
357
    {
358 2
        $this->majorUnit = $pUnit;
359 2
        return $this;
360
    }
361
362
    /**
363
     * @return Outline
364
     */
365 28
    public function getOutline()
366
    {
367 28
        return $this->outline;
368
    }
369
370
    /**
371
     * @param Outline $outline
372
     * @return Axis
373
     */
374
    public function setOutline($outline)
375
    {
376
        $this->outline = $outline;
377
        return $this;
378
    }
379
380
    /**
381
     * Get hash code
382
     *
383
     * @return string Hash code
384
     */
385 59
    public function getHashCode()
386
    {
387 59
        return md5($this->title . $this->formatCode . __CLASS__);
388
    }
389
390
    /**
391
     * Hash index
392
     *
393
     * @var string
394
     */
395
    private $hashIndex;
396
397
    /**
398
     * Get hash index
399
     *
400
     * Note that this index may vary during script execution! Only reliable moment is
401
     * while doing a write of a workbook and when changes are not allowed.
402
     *
403
     * @return string Hash index
404
     */
405 1
    public function getHashIndex()
406
    {
407 1
        return $this->hashIndex;
408
    }
409
410
    /**
411
     * Set hash index
412
     *
413
     * Note that this index may vary during script execution! Only reliable moment is
414
     * while doing a write of a workbook and when changes are not allowed.
415
     *
416
     * @param string $value Hash index
417
     * @return $this
418
     */
419 1
    public function setHashIndex($value)
420
    {
421 1
        $this->hashIndex = $value;
422 1
        return $this;
423
    }
424
425
    /**
426
     * Axis is hidden ?
427
     * @return boolean
428
     */
429 29
    public function isVisible()
430
    {
431 29
        return $this->isVisible;
432
    }
433
434
    /**
435
     * Hide an axis
436
     *
437
     * @param boolean $value delete
438
     * @return $this
439
     */
440 3
    public function setIsVisible($value)
441
    {
442 3
        $this->isVisible = (bool)$value;
443 3
        return $this;
444
    }
445
}
446