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

Series::setOutline()   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 1
Bugs 0 Features 0
Metric Value
c 1
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\Fill;
22
use PhpOffice\PhpPresentation\Style\Font;
23
use PhpOffice\PhpPresentation\Style\Outline;
24
25
/**
26
 * \PhpOffice\PhpPresentation\Shape\Chart\Series
27
 */
28
class Series implements ComparableInterface
29
{
30
    /* Label positions */
31
    const LABEL_BESTFIT = 'bestFit';
32
    const LABEL_BOTTOM = 'b';
33
    const LABEL_CENTER = 'ctr';
34
    const LABEL_INSIDEBASE = 'inBase';
35
    const LABEL_INSIDEEND = 'inEnd';
36
    const LABEL_LEFT = 'i';
37
    const LABEL_OUTSIDEEND = 'outEnd';
38
    const LABEL_RIGHT = 'r';
39
    const LABEL_TOP = 't';
40
41
    /**
42
     * DataPointFills (key/value)
43
     *
44
     * @var array
45
     */
46
    private $dataPointFills = array();
47
48
    /**
49
     * Data Label Number Format
50
     *
51
     * @var string
52
     */
53
    private $DlblNumFormat = '';
54
55
    /**
56
     * Fill
57
     *
58
     * @var \PhpOffice\PhpPresentation\Style\Fill
59
     */
60
    private $fill;
61
62
    /**
63
     * Font
64
     *
65
     * @var \PhpOffice\PhpPresentation\Style\Font
66
     */
67
    private $font;
68
69
    /**
70
     * Label position
71
     *
72
     * @var string
73
     */
74
    private $labelPosition = 'ctr';
75
76
    /**
77
     * @var Marker
78
     */
79
    protected $marker;
80
81
    /**
82
     * @var Outline
83
     */
84
    protected $outline;
85
86
    /**
87
     * ShowCategoryName
88
     *
89
     * @var boolean
90
     */
91
    private $showCategoryName = false;
92
93
    /**
94
     * ShowLeaderLines
95
     *
96
     * @var boolean
97
     */
98
    private $showLeaderLines = true;
99
100
    /**
101
     * ShowPercentage
102
     *
103
     * @var boolean
104
     */
105
    private $showPercentage = false;
106
107
    /**
108
     * ShowSeriesName
109
     *
110
     * @var boolean
111
     */
112
    private $showSeriesName = false;
113
114
    /**
115
     * ShowValue
116
     *
117
     * @var boolean
118
     */
119
    private $showValue = true;
120
121
    /**
122
     * Title
123
     *
124
     * @var string
125
     */
126
    private $title = 'Series Title';
127
128
    /**
129
     * Values (key/value)
130
     *
131
     * @var array
132
     */
133
    private $values = array();
134
135
    /**
136
     * Hash index
137
     *
138
     * @var string
139
     */
140
    private $hashIndex;
141
142
    /**
143
     * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Series instance
144
     *
145
     * @param string $title  Title
146
     * @param array  $values Values
147
     */
148 76
    public function __construct($title = 'Series Title', $values = array())
149
    {
150 76
        $this->fill = new Fill();
151 76
        $this->font = new Font();
152 76
        $this->font->setName('Calibri');
153 76
        $this->font->setSize(9);
154 76
        $this->title  = $title;
155 76
        $this->values = $values;
156 76
        $this->marker = new Marker();
157 76
    }
158
159
    /**
160
     * Get Title
161
     *
162
     * @return string
163
     */
164 40
    public function getTitle()
165
    {
166 40
        return $this->title;
167
    }
168
169
    /**
170
     * Set Title
171
     *
172
     * @param  string                           $value
173
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
174
     */
175 1
    public function setTitle($value = 'Series Title')
176
    {
177 1
        $this->title = $value;
178
179 1
        return $this;
180
    }
181
182
    /**
183
     * Get Data Label NumFormat
184
     *
185
     * @return string
186
     */
187 1
    public function getDlblNumFormat()
188
    {
189 1
        return $this->DlblNumFormat;
190
    }
191
192
    /**
193
     * Has Data Label NumFormat
194
     *
195
     * @return string
196
     */
197 3
    public function hasDlblNumFormat()
198
    {
199 3
        return !empty($this->DlblNumFormat);
200
    }
201
202
    /**
203
     * Set Data Label NumFormat
204
     *
205
     * @param  string $value
206
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
207
     */
208 1
    public function setDlblNumFormat($value = '')
209
    {
210 1
        $this->DlblNumFormat = $value;
211 1
        return $this;
212
    }
213
214
    /**
215
     * Get Fill
216
     *
217
     * @return \PhpOffice\PhpPresentation\Style\Fill
218
     */
219 36
    public function getFill()
220
    {
221 36
        return $this->fill;
222
    }
223
224
    /**
225
     * Set Fill
226
     *
227
     * @param \PhpOffice\PhpPresentation\Style\Fill $fill
228
     * @return Series
229
     */
230 1
    public function setFill(Fill $fill = null)
231
    {
232 1
        $this->fill = $fill;
233 1
        return $this;
234
    }
235
236
    /**
237
     * Get DataPointFill
238
     *
239
     * @param  int                      $dataPointIndex Data point index.
240
     * @return \PhpOffice\PhpPresentation\Style\Fill
241
     */
242 11
    public function getDataPointFill($dataPointIndex)
243
    {
244 11
        if (!isset($this->dataPointFills[$dataPointIndex])) {
245 11
            $this->dataPointFills[$dataPointIndex] = new Fill();
246 11
        }
247
248 11
        return $this->dataPointFills[$dataPointIndex];
249
    }
250
251
    /**
252
     * Get DataPointFills
253
     *
254
     * @return array
255
     */
256 28
    public function getDataPointFills()
257
    {
258 28
        return $this->dataPointFills;
259
    }
260
261
    /**
262
     * Get Values
263
     *
264
     * @return array
265
     */
266 41
    public function getValues()
267
    {
268 41
        return $this->values;
269
    }
270
271
    /**
272
     * Set Values
273
     *
274
     * @param  array                            $value
275
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
276
     */
277 1
    public function setValues($value = array())
278
    {
279 1
        $this->values = $value;
280
281 1
        return $this;
282
    }
283
284
    /**
285
     * Add Value
286
     *
287
     * @param  mixed                            $key
288
     * @param  mixed                            $value
289
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
290
     */
291 1
    public function addValue($key, $value)
292
    {
293 1
        $this->values[$key] = $value;
294
295 1
        return $this;
296
    }
297
298
    /**
299
     * Get ShowSeriesName
300
     *
301
     * @return boolean
302
     */
303 23
    public function hasShowSeriesName()
304
    {
305 23
        return $this->showSeriesName;
306
    }
307
308
    /**
309
     * Set ShowSeriesName
310
     *
311
     * @param  boolean                          $value
312
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
313
     */
314 11
    public function setShowSeriesName($value)
315
    {
316 11
        $this->showSeriesName = $value;
317
318 11
        return $this;
319
    }
320
321
    /**
322
     * Get ShowCategoryName
323
     *
324
     * @return boolean
325
     */
326 23
    public function hasShowCategoryName()
327
    {
328 23
        return $this->showCategoryName;
329
    }
330
331
    /**
332
     * Set ShowCategoryName
333
     *
334
     * @param  boolean                          $value
335
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
336
     */
337 1
    public function setShowCategoryName($value)
338
    {
339 1
        $this->showCategoryName = $value;
340
341 1
        return $this;
342
    }
343
344
    /**
345
     * Get ShowValue
346
     *
347
     * @return boolean
348
     */
349 23
    public function hasShowValue()
350
    {
351 23
        return $this->showValue;
352
    }
353
354
    /**
355
     * Set ShowValue
356
     *
357
     * @param  boolean                          $value
358
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
359
     */
360 1
    public function setShowValue($value)
361
    {
362 1
        $this->showValue = $value;
363
364 1
        return $this;
365
    }
366
367
    /**
368
     * Get ShowPercentage
369
     *
370
     * @return boolean
371
     */
372 23
    public function hasShowPercentage()
373
    {
374 23
        return $this->showPercentage;
375
    }
376
377
    /**
378
     * Set ShowPercentage
379
     *
380
     * @param  boolean                          $value
381
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
382
     */
383 1
    public function setShowPercentage($value)
384
    {
385 1
        $this->showPercentage = $value;
386
387 1
        return $this;
388
    }
389
390
    /**
391
     * Get ShowLeaderLines
392
     *
393
     * @return boolean
394
     */
395 23
    public function hasShowLeaderLines()
396
    {
397 23
        return $this->showLeaderLines;
398
    }
399
400
    /**
401
     * Set ShowLeaderLines
402
     *
403
     * @param  boolean                          $value
404
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
405
     */
406 1
    public function setShowLeaderLines($value)
407
    {
408 1
        $this->showLeaderLines = $value;
409
410 1
        return $this;
411
    }
412
413
    /**
414
     * Get font
415
     *
416
     * @return \PhpOffice\PhpPresentation\Style\Font
417
     */
418 41
    public function getFont()
419
    {
420 41
        return $this->font;
421
    }
422
423
    /**
424
     * Set font
425
     *
426
     * @param  \PhpOffice\PhpPresentation\Style\Font               $pFont Font
427
     * @throws \Exception
428
     * @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
429
     */
430 1
    public function setFont(Font $pFont = null)
431
    {
432 1
        $this->font = $pFont;
433
434 1
        return $this;
435
    }
436
437
    /**
438
     * Get label position
439
     *
440
     * @return string
441
     */
442 7
    public function getLabelPosition()
443
    {
444 7
        return $this->labelPosition;
445
    }
446
447
    /**
448
     * Set label position
449
     *
450
     * @param  string                           $value
451
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
452
     */
453 1
    public function setLabelPosition($value)
454
    {
455 1
        $this->labelPosition = $value;
456
457 1
        return $this;
458
    }
459
460
    /**
461
     * @return Marker
462
     */
463 19
    public function getMarker()
464
    {
465 19
        return $this->marker;
466
    }
467
468
    /**
469
     * @param Marker $marker
470
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
471
     */
472 1
    public function setMarker(Marker $marker)
473
    {
474 1
        $this->marker = $marker;
475 1
        return $this;
476
    }
477
478
    /**
479
     * @return Outline
480
     */
481 19
    public function getOutline()
482
    {
483 19
        return $this->outline;
484
    }
485
486
    /**
487
     * @param Outline $outline
488
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
489
     */
490 5
    public function setOutline(Outline $outline)
491
    {
492 5
        $this->outline = $outline;
493 5
        return $this;
494
    }
495
496
    /**
497
     * Get hash code
498
     *
499
     * @return string Hash code
500
     */
501 46
    public function getHashCode()
502
    {
503 46
        return md5((is_null($this->fill) ? 'null' : $this->fill->getHashCode()) . (is_null($this->font) ? 'null' : $this->font->getHashCode()) . var_export($this->values, true) . var_export($this, true) . __CLASS__);
504
    }
505
506
    /**
507
     * Get hash index
508
     *
509
     * Note that this index may vary during script execution! Only reliable moment is
510
     * while doing a write of a workbook and when changes are not allowed.
511
     *
512
     * @return string Hash index
513
     */
514 2
    public function getHashIndex()
515
    {
516 2
        return $this->hashIndex;
517
    }
518
519
    /**
520
     * Set hash index
521
     *
522
     * Note that this index may vary during script execution! Only reliable moment is
523
     * while doing a write of a workbook and when changes are not allowed.
524
     *
525
     * @param string $value Hash index
526
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Series
527
     */
528 1
    public function setHashIndex($value)
529
    {
530 1
        $this->hashIndex = $value;
531 1
        return $this;
532
    }
533
534
    /**
535
     * @return mixed
536
     * @link http://php.net/manual/en/language.oop5.cloning.php
537
     */
538
    public function __clone()
539
    {
540
        $this->font = clone $this->font;
541
        $this->marker = clone $this->marker;
542
        if (is_object($this->outline)) {
543
            $this->outline = clone $this->outline;
544
        }
545
    }
546
}
547