Font::setBold()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Style;
4
5
use PhpOffice\PhpSpreadsheet\Chart\ChartColor;
6
7
class Font extends Supervisor
8
{
9
    // Underline types
10
    const UNDERLINE_NONE = 'none';
11
    const UNDERLINE_DOUBLE = 'double';
12
    const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting';
13
    const UNDERLINE_SINGLE = 'single';
14
    const UNDERLINE_SINGLEACCOUNTING = 'singleAccounting';
15
16
    const CAP_ALL = 'all';
17
    const CAP_SMALL = 'small';
18
    const CAP_NONE = 'none';
19
    private const VALID_CAPS = [self::CAP_ALL, self::CAP_SMALL, self::CAP_NONE];
20
21
    protected ?string $cap = null;
22
23
    public const DEFAULT_FONT_NAME = 'Calibri';
24
25
    /**
26
     * Font Name.
27
     */
28
    protected ?string $name = self::DEFAULT_FONT_NAME;
29
30
    /**
31
     * The following 7 are used only for chart titles, I think.
32
     */
33
    private string $latin = '';
34
35
    private string $eastAsian = '';
36
37
    private string $complexScript = '';
38
39
    private int $baseLine = 0;
40
41
    private string $strikeType = '';
42
43
    private ?ChartColor $underlineColor = null;
44
45
    private ?ChartColor $chartColor = null;
46
    // end of chart title items
47
48
    /**
49
     * Font Size.
50
     */
51
    protected ?float $size = 11;
52
53
    /**
54
     * Bold.
55
     */
56
    protected ?bool $bold = false;
57
58
    /**
59
     * Italic.
60
     */
61
    protected ?bool $italic = false;
62
63
    /**
64
     * Superscript.
65
     */
66
    protected ?bool $superscript = false;
67
68
    /**
69
     * Subscript.
70
     */
71
    protected ?bool $subscript = false;
72
73
    /**
74
     * Underline.
75
     */
76
    protected ?string $underline = self::UNDERLINE_NONE;
77
78
    /**
79
     * Strikethrough.
80
     */
81
    protected ?bool $strikethrough = false;
82
83
    /**
84
     * Foreground color.
85
     */
86
    protected Color $color;
87
88
    public ?int $colorIndex = null;
89
90
    protected string $scheme = '';
91
92
    /**
93
     * Create a new Font.
94
     *
95
     * @param bool $isSupervisor Flag indicating if this is a supervisor or not
96
     *                                    Leave this value at default unless you understand exactly what
97
     *                                        its ramifications are
98
     * @param bool $isConditional Flag indicating if this is a conditional style or not
99
     *                                    Leave this value at default unless you understand exactly what
100
     *                                        its ramifications are
101
     */
102 10722
    public function __construct(bool $isSupervisor = false, bool $isConditional = false)
103
    {
104
        // Supervisor?
105 10722
        parent::__construct($isSupervisor);
106
107
        // Initialise values
108 10722
        if ($isConditional) {
109 402
            $this->name = null;
110 402
            $this->size = null;
111 402
            $this->bold = null;
112 402
            $this->italic = null;
113 402
            $this->superscript = null;
114 402
            $this->subscript = null;
115 402
            $this->underline = null;
116 402
            $this->strikethrough = null;
117 402
            $this->color = new Color(Color::COLOR_BLACK, $isSupervisor, $isConditional);
118
        } else {
119 10719
            $this->color = new Color(Color::COLOR_BLACK, $isSupervisor);
120
        }
121
        // bind parent if we are a supervisor
122 10722
        if ($isSupervisor) {
123 10537
            $this->color->bindParent($this, 'color');
124
        }
125
    }
126
127
    /**
128
     * Get the shared style component for the currently active cell in currently active sheet.
129
     * Only used for style supervisor.
130
     */
131 70
    public function getSharedComponent(): self
132
    {
133
        /** @var Style $parent */
134 70
        $parent = $this->parent;
135
136 70
        return $parent->getSharedComponent()->getFont();
137
    }
138
139
    /**
140
     * Build style array from subcomponents.
141
     *
142
     * @param mixed[] $array
143
     *
144
     * @return array{font: mixed[]}
145
     */
146 105
    public function getStyleArray(array $array): array
147
    {
148 105
        return ['font' => $array];
149
    }
150
151
    /**
152
     * Apply styles from array.
153
     *
154
     * <code>
155
     * $spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
156
     *     [
157
     *         'name' => 'Arial',
158
     *         'bold' => TRUE,
159
     *         'italic' => FALSE,
160
     *         'underline' => \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE,
161
     *         'strikethrough' => FALSE,
162
     *         'color' => [
163
     *             'rgb' => '808080'
164
     *         ]
165
     *     ]
166
     * );
167
     * </code>
168
     *
169
     * @param array{name?: string, latin?: string, eastAsian?: string, complexScript?: string, bold?: bool, italic?: bool, superscript?: bool, subscript?: bool, underline?: bool|string, strikethrough?: bool, color?: string[], size?: ?int, chartColor?: ChartColor, scheme?: string, cap?: string} $styleArray Array containing style information
170
     *
171
     * @return $this
172
     */
173 270
    public function applyFromArray(array $styleArray): static
174
    {
175 270
        if ($this->isSupervisor) {
176 1
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray));
177
        } else {
178 270
            if (isset($styleArray['name'])) {
179 178
                $this->setName($styleArray['name']);
180
            }
181 270
            if (isset($styleArray['latin'])) {
182 25
                $this->setLatin($styleArray['latin']);
183
            }
184 270
            if (isset($styleArray['eastAsian'])) {
185 17
                $this->setEastAsian($styleArray['eastAsian']);
186
            }
187 270
            if (isset($styleArray['complexScript'])) {
188 17
                $this->setComplexScript($styleArray['complexScript']);
189
            }
190 270
            if (isset($styleArray['bold'])) {
191 177
                $this->setBold($styleArray['bold']);
192
            }
193 270
            if (isset($styleArray['italic'])) {
194 121
                $this->setItalic($styleArray['italic']);
195
            }
196 270
            if (isset($styleArray['superscript'])) {
197 30
                $this->setSuperscript($styleArray['superscript']);
198
            }
199 270
            if (isset($styleArray['subscript'])) {
200 28
                $this->setSubscript($styleArray['subscript']);
201
            }
202 270
            if (isset($styleArray['underline'])) {
203 66
                $this->setUnderline($styleArray['underline']);
204
            }
205 270
            if (isset($styleArray['strikethrough'])) {
206 59
                $this->setStrikethrough($styleArray['strikethrough']);
207
            }
208 270
            if (isset($styleArray['color'])) {
209
                /** @var array{rgb?: string, argb?: string, theme?: int} */
210 118
                $temp = $styleArray['color'];
211 118
                $this->getColor()
212 118
                    ->applyFromArray($temp);
213
            }
214 270
            if (isset($styleArray['size'])) {
215 118
                $this->setSize($styleArray['size']);
216
            }
217 270
            if (isset($styleArray['chartColor'])) {
218 13
                $this->chartColor = $styleArray['chartColor'];
219
            }
220 270
            if (isset($styleArray['scheme'])) {
221 51
                $this->setScheme($styleArray['scheme']);
222
            }
223 270
            if (isset($styleArray['cap'])) {
224 21
                $this->setCap($styleArray['cap']);
225
            }
226
        }
227
228 270
        return $this;
229
    }
230
231
    /**
232
     * Get Name.
233
     */
234 1215
    public function getName(): ?string
235
    {
236 1215
        if ($this->isSupervisor) {
237 30
            return $this->getSharedComponent()->getName();
238
        }
239
240 1215
        return $this->name;
241
    }
242
243 53
    public function getLatin(): string
244
    {
245 53
        if ($this->isSupervisor) {
246 8
            return $this->getSharedComponent()->getLatin();
247
        }
248
249 53
        return $this->latin;
250
    }
251
252 53
    public function getEastAsian(): string
253
    {
254 53
        if ($this->isSupervisor) {
255 8
            return $this->getSharedComponent()->getEastAsian();
256
        }
257
258 53
        return $this->eastAsian;
259
    }
260
261 53
    public function getComplexScript(): string
262
    {
263 53
        if ($this->isSupervisor) {
264 8
            return $this->getSharedComponent()->getComplexScript();
265
        }
266
267 53
        return $this->complexScript;
268
    }
269
270
    /**
271
     * Set Name and turn off Scheme.
272
     */
273 996
    public function setName(string $fontname): self
274
    {
275 996
        if ($fontname == '') {
276 1
            $fontname = 'Calibri';
277
        }
278 996
        if ($this->isSupervisor) {
279 41
            $styleArray = $this->getStyleArray(['name' => $fontname]);
280 41
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
281
        } else {
282 996
            $this->name = $fontname;
283
        }
284
285 996
        return $this->setScheme('');
286
    }
287
288 48
    public function setLatin(string $fontname): self
289
    {
290 48
        if ($fontname == '') {
291 12
            $fontname = 'Calibri';
292
        }
293 48
        if (!$this->isSupervisor) {
294 48
            $this->latin = $fontname;
295
        } else {
296
            // should never be true
297
            // @codeCoverageIgnoreStart
298
            $styleArray = $this->getStyleArray(['latin' => $fontname]);
299
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
300
            // @codeCoverageIgnoreEnd
301
        }
302
303 48
        return $this;
304
    }
305
306 41
    public function setEastAsian(string $fontname): self
307
    {
308 41
        if ($fontname == '') {
309 12
            $fontname = 'Calibri';
310
        }
311 41
        if (!$this->isSupervisor) {
312 41
            $this->eastAsian = $fontname;
313
        } else {
314
            // should never be true
315
            // @codeCoverageIgnoreStart
316
            $styleArray = $this->getStyleArray(['eastAsian' => $fontname]);
317
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
318
            // @codeCoverageIgnoreEnd
319
        }
320
321 41
        return $this;
322
    }
323
324 41
    public function setComplexScript(string $fontname): self
325
    {
326 41
        if ($fontname == '') {
327 12
            $fontname = 'Calibri';
328
        }
329 41
        if (!$this->isSupervisor) {
330 41
            $this->complexScript = $fontname;
331
        } else {
332
            // should never be true
333
            // @codeCoverageIgnoreStart
334
            $styleArray = $this->getStyleArray(['complexScript' => $fontname]);
335
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
336
            // @codeCoverageIgnoreEnd
337
        }
338
339 41
        return $this;
340
    }
341
342
    /**
343
     * Get Size.
344
     */
345 1161
    public function getSize(): ?float
346
    {
347 1161
        if ($this->isSupervisor) {
348 24
            return $this->getSharedComponent()->getSize();
349
        }
350
351 1161
        return $this->size;
352
    }
353
354
    /**
355
     * Set Size.
356
     *
357
     * @param mixed $sizeInPoints A float representing the value of a positive measurement in points (1/72 of an inch)
358
     *
359
     * @return $this
360
     */
361 926
    public function setSize(mixed $sizeInPoints, bool $nullOk = false): static
362
    {
363 926
        if (is_string($sizeInPoints) || is_int($sizeInPoints)) {
364 253
            $sizeInPoints = (float) $sizeInPoints; // $pValue = 0 if given string is not numeric
365
        }
366
367
        // Size must be a positive floating point number
368
        // ECMA-376-1:2016, part 1, chapter 18.4.11 sz (Font Size), p. 1536
369 926
        if (!is_float($sizeInPoints) || !($sizeInPoints > 0)) {
370 57
            if (!$nullOk || $sizeInPoints !== null) {
371 1
                $sizeInPoints = 10.0;
372
            }
373
        }
374
375 926
        if ($this->isSupervisor) {
376 20
            $styleArray = $this->getStyleArray(['size' => $sizeInPoints]);
377 20
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
378
        } else {
379 926
            $this->size = $sizeInPoints;
380
        }
381
382 926
        return $this;
383
    }
384
385
    /**
386
     * Get Bold.
387
     */
388 1137
    public function getBold(): ?bool
389
    {
390 1137
        if ($this->isSupervisor) {
391 48
            return $this->getSharedComponent()->getBold();
392
        }
393
394 1137
        return $this->bold;
395
    }
396
397
    /**
398
     * Set Bold.
399
     *
400
     * @return $this
401
     */
402 759
    public function setBold(bool $bold): static
403
    {
404 759
        if ($this->isSupervisor) {
405 68
            $styleArray = $this->getStyleArray(['bold' => $bold]);
406 68
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
407
        } else {
408 759
            $this->bold = $bold;
409
        }
410
411 759
        return $this;
412
    }
413
414
    /**
415
     * Get Italic.
416
     */
417 1125
    public function getItalic(): ?bool
418
    {
419 1125
        if ($this->isSupervisor) {
420 35
            return $this->getSharedComponent()->getItalic();
421
        }
422
423 1125
        return $this->italic;
424
    }
425
426
    /**
427
     * Set Italic.
428
     *
429
     * @return $this
430
     */
431 663
    public function setItalic(bool $italic): static
432
    {
433 663
        if ($this->isSupervisor) {
434 19
            $styleArray = $this->getStyleArray(['italic' => $italic]);
435 19
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
436
        } else {
437 663
            $this->italic = $italic;
438
        }
439
440 663
        return $this;
441
    }
442
443
    /**
444
     * Get Superscript.
445
     */
446 994
    public function getSuperscript(): ?bool
447
    {
448 994
        if ($this->isSupervisor) {
449 13
            return $this->getSharedComponent()->getSuperscript();
450
        }
451
452 994
        return $this->superscript;
453
    }
454
455
    /**
456
     * Set Superscript.
457
     *
458
     * @return $this
459
     */
460 41
    public function setSuperscript(bool $superscript): static
461
    {
462 41
        if ($this->isSupervisor) {
463 5
            $styleArray = $this->getStyleArray(['superscript' => $superscript]);
464 5
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
465
        } else {
466 41
            $this->superscript = $superscript;
467 41
            if ($this->superscript) {
468 29
                $this->subscript = false;
469
            }
470
        }
471
472 41
        return $this;
473
    }
474
475
    /**
476
     * Get Subscript.
477
     */
478 994
    public function getSubscript(): ?bool
479
    {
480 994
        if ($this->isSupervisor) {
481 13
            return $this->getSharedComponent()->getSubscript();
482
        }
483
484 994
        return $this->subscript;
485
    }
486
487
    /**
488
     * Set Subscript.
489
     *
490
     * @return $this
491
     */
492 39
    public function setSubscript(bool $subscript): static
493
    {
494 39
        if ($this->isSupervisor) {
495 3
            $styleArray = $this->getStyleArray(['subscript' => $subscript]);
496 3
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
497
        } else {
498 39
            $this->subscript = $subscript;
499 39
            if ($this->subscript) {
500 27
                $this->superscript = false;
501
            }
502
        }
503
504 39
        return $this;
505
    }
506
507 42
    public function getBaseLine(): int
508
    {
509 42
        if ($this->isSupervisor) {
510 8
            return $this->getSharedComponent()->getBaseLine();
511
        }
512
513 42
        return $this->baseLine;
514
    }
515
516 32
    public function setBaseLine(int $baseLine): self
517
    {
518 32
        if (!$this->isSupervisor) {
519 32
            $this->baseLine = $baseLine;
520
        } else {
521
            // should never be true
522
            // @codeCoverageIgnoreStart
523
            $styleArray = $this->getStyleArray(['baseLine' => $baseLine]);
524
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
525
            // @codeCoverageIgnoreEnd
526
        }
527
528 32
        return $this;
529
    }
530
531 42
    public function getStrikeType(): string
532
    {
533 42
        if ($this->isSupervisor) {
534 8
            return $this->getSharedComponent()->getStrikeType();
535
        }
536
537 42
        return $this->strikeType;
538
    }
539
540 35
    public function setStrikeType(string $strikeType): self
541
    {
542 35
        if (!$this->isSupervisor) {
543 35
            $this->strikeType = $strikeType;
544
        } else {
545
            // should never be true
546
            // @codeCoverageIgnoreStart
547
            $styleArray = $this->getStyleArray(['strikeType' => $strikeType]);
548
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
549
            // @codeCoverageIgnoreEnd
550
        }
551
552 35
        return $this;
553
    }
554
555 42
    public function getUnderlineColor(): ?ChartColor
556
    {
557 42
        if ($this->isSupervisor) {
558 8
            return $this->getSharedComponent()->getUnderlineColor();
559
        }
560
561 42
        return $this->underlineColor;
562
    }
563
564
    /** @param array{value: null|string, alpha: null|int|string, brightness?: null|int|string, type: null|string} $colorArray */
565 8
    public function setUnderlineColor(array $colorArray): self
566
    {
567 8
        if (!$this->isSupervisor) {
568 8
            $this->underlineColor = new ChartColor($colorArray);
569
        } else {
570
            // should never be true
571
            // @codeCoverageIgnoreStart
572
            $styleArray = $this->getStyleArray(['underlineColor' => $colorArray]);
573
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
574
            // @codeCoverageIgnoreEnd
575
        }
576
577 8
        return $this;
578
    }
579
580 61
    public function getChartColor(): ?ChartColor
581
    {
582 61
        if ($this->isSupervisor) {
583 8
            return $this->getSharedComponent()->getChartColor();
584
        }
585
586 61
        return $this->chartColor;
587
    }
588
589
    /** @param array{value: null|string, alpha: null|int|string, brightness?: null|int|string, type: null|string} $colorArray */
590 30
    public function setChartColor(array $colorArray): self
591
    {
592 30
        if (!$this->isSupervisor) {
593 30
            $this->chartColor = new ChartColor($colorArray);
594
        } else {
595
            // should never be true
596
            // @codeCoverageIgnoreStart
597
            $styleArray = $this->getStyleArray(['chartColor' => $colorArray]);
598
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
599
            // @codeCoverageIgnoreEnd
600
        }
601
602 30
        return $this;
603
    }
604
605 12
    public function setChartColorFromObject(?ChartColor $chartColor): self
606
    {
607 12
        $this->chartColor = $chartColor;
608
609 12
        return $this;
610
    }
611
612
    /**
613
     * Get Underline.
614
     */
615 1051
    public function getUnderline(): ?string
616
    {
617 1051
        if ($this->isSupervisor) {
618 25
            return $this->getSharedComponent()->getUnderline();
619
        }
620
621 1051
        return $this->underline;
622
    }
623
624
    /**
625
     * Set Underline.
626
     *
627
     * @param bool|string $underlineStyle \PhpOffice\PhpSpreadsheet\Style\Font underline type
628
     *                                    If a boolean is passed, then TRUE equates to UNDERLINE_SINGLE,
629
     *                                        false equates to UNDERLINE_NONE
630
     *
631
     * @return $this
632
     */
633 559
    public function setUnderline($underlineStyle): static
634
    {
635 559
        if (is_bool($underlineStyle)) {
636 10
            $underlineStyle = ($underlineStyle) ? self::UNDERLINE_SINGLE : self::UNDERLINE_NONE;
637 552
        } elseif ($underlineStyle == '') {
638 2
            $underlineStyle = self::UNDERLINE_NONE;
639
        }
640 559
        if ($this->isSupervisor) {
641 34
            $styleArray = $this->getStyleArray(['underline' => $underlineStyle]);
642 34
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
643
        } else {
644 559
            $this->underline = $underlineStyle;
645
        }
646
647 559
        return $this;
648
    }
649
650
    /**
651
     * Get Strikethrough.
652
     */
653 999
    public function getStrikethrough(): ?bool
654
    {
655 999
        if ($this->isSupervisor) {
656 19
            return $this->getSharedComponent()->getStrikethrough();
657
        }
658
659 999
        return $this->strikethrough;
660
    }
661
662
    /**
663
     * Set Strikethrough.
664
     *
665
     * @return $this
666
     */
667 524
    public function setStrikethrough(bool $strikethru): static
668
    {
669 524
        if ($this->isSupervisor) {
670 10
            $styleArray = $this->getStyleArray(['strikethrough' => $strikethru]);
671 10
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
672
        } else {
673 524
            $this->strikethrough = $strikethru;
674
        }
675
676 524
        return $this;
677
    }
678
679
    /**
680
     * Get Color.
681
     */
682 1557
    public function getColor(): Color
683
    {
684 1557
        return $this->color;
685
    }
686
687
    /**
688
     * Set Color.
689
     *
690
     * @return $this
691
     */
692 84
    public function setColor(Color $color): static
693
    {
694
        // make sure parameter is a real color and not a supervisor
695 84
        $color = $color->getIsSupervisor() ? $color->getSharedComponent() : $color;
696
697 84
        if ($this->isSupervisor) {
698 11
            $styleArray = $this->getColor()->getStyleArray(['argb' => $color->getARGB()]);
699 11
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
700
        } else {
701 73
            $this->color = $color;
702
        }
703
704 84
        return $this;
705
    }
706
707 1311
    private function hashChartColor(?ChartColor $underlineColor): string
708
    {
709 1311
        if ($underlineColor === null) {
710 1311
            return '';
711
        }
712
713 1
        return
714 1
            $underlineColor->getValue()
715 1
            . $underlineColor->getType()
716 1
            . (string) $underlineColor->getAlpha();
717
    }
718
719
    /**
720
     * Get hash code.
721
     *
722
     * @return string Hash code
723
     */
724 1311
    public function getHashCode(): string
725
    {
726 1311
        if ($this->isSupervisor) {
727 1
            return $this->getSharedComponent()->getHashCode();
728
        }
729
730 1311
        return md5(
731 1311
            $this->name
732 1311
            . $this->size
733 1311
            . ($this->bold ? 't' : 'f')
734 1311
            . ($this->italic ? 't' : 'f')
735 1311
            . ($this->superscript ? 't' : 'f')
736 1311
            . ($this->subscript ? 't' : 'f')
737 1311
            . $this->underline
738 1311
            . ($this->strikethrough ? 't' : 'f')
739 1311
            . $this->color->getHashCode()
740 1311
            . $this->scheme
741 1311
            . implode(
742 1311
                '*',
743 1311
                [
744 1311
                    $this->latin,
745 1311
                    $this->eastAsian,
746 1311
                    $this->complexScript,
747 1311
                    $this->strikeType,
748 1311
                    $this->hashChartColor($this->chartColor),
749 1311
                    $this->hashChartColor($this->underlineColor),
750 1311
                    (string) $this->baseLine,
751 1311
                    (string) $this->cap,
752 1311
                ]
753 1311
            )
754 1311
            . __CLASS__
755 1311
        );
756
    }
757
758
    /** @return mixed[] */
759 14
    protected function exportArray1(): array
760
    {
761 14
        $exportedArray = [];
762 14
        $this->exportArray2($exportedArray, 'baseLine', $this->getBaseLine());
763 14
        $this->exportArray2($exportedArray, 'bold', $this->getBold());
764 14
        $this->exportArray2($exportedArray, 'cap', $this->getCap());
765 14
        $this->exportArray2($exportedArray, 'chartColor', $this->getChartColor());
766 14
        $this->exportArray2($exportedArray, 'color', $this->getColor());
767 14
        $this->exportArray2($exportedArray, 'complexScript', $this->getComplexScript());
768 14
        $this->exportArray2($exportedArray, 'eastAsian', $this->getEastAsian());
769 14
        $this->exportArray2($exportedArray, 'italic', $this->getItalic());
770 14
        $this->exportArray2($exportedArray, 'latin', $this->getLatin());
771 14
        $this->exportArray2($exportedArray, 'name', $this->getName());
772 14
        $this->exportArray2($exportedArray, 'scheme', $this->getScheme());
773 14
        $this->exportArray2($exportedArray, 'size', $this->getSize());
774 14
        $this->exportArray2($exportedArray, 'strikethrough', $this->getStrikethrough());
775 14
        $this->exportArray2($exportedArray, 'strikeType', $this->getStrikeType());
776 14
        $this->exportArray2($exportedArray, 'subscript', $this->getSubscript());
777 14
        $this->exportArray2($exportedArray, 'superscript', $this->getSuperscript());
778 14
        $this->exportArray2($exportedArray, 'underline', $this->getUnderline());
779 14
        $this->exportArray2($exportedArray, 'underlineColor', $this->getUnderlineColor());
780
781 14
        return $exportedArray;
782
    }
783
784 395
    public function getScheme(): string
785
    {
786 395
        if ($this->isSupervisor) {
787 9
            return $this->getSharedComponent()->getScheme();
788
        }
789
790 395
        return $this->scheme;
791
    }
792
793 996
    public function setScheme(string $scheme): self
794
    {
795 996
        if ($scheme === '' || $scheme === 'major' || $scheme === 'minor') {
796 996
            if ($this->isSupervisor) {
797 41
                $styleArray = $this->getStyleArray(['scheme' => $scheme]);
798 41
                $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
799
            } else {
800 996
                $this->scheme = $scheme;
801
            }
802
        }
803
804 996
        return $this;
805
    }
806
807
    /**
808
     * Set capitalization attribute. If not one of the permitted
809
     * values (all, small, or none), set it to null.
810
     * This will be honored only for the font for chart titles.
811
     * None is distinguished from null because null will inherit
812
     * the current value, whereas 'none' will override it.
813
     */
814 21
    public function setCap(string $cap): self
815
    {
816 21
        $this->cap = in_array($cap, self::VALID_CAPS, true) ? $cap : null;
817
818 21
        return $this;
819
    }
820
821 28
    public function getCap(): ?string
822
    {
823 28
        return $this->cap;
824
    }
825
826 19
    public function setHyperlinkTheme(): self
827
    {
828 19
        $this->color->setHyperlinkTheme();
829 19
        $this->setUnderline(self::UNDERLINE_SINGLE);
830
831 19
        return $this;
832
    }
833
834
    /**
835
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
836
     */
837 1117
    public function __clone()
838
    {
839 1117
        $this->color = clone $this->color;
840 1117
        $this->chartColor = ($this->chartColor === null) ? null : clone $this->chartColor;
841 1117
        $this->underlineColor = ($this->underlineColor === null) ? null : clone $this->underlineColor;
842
    }
843
}
844