Passed
Push — master ( 84b7ab...30369c )
by
unknown
18:09 queued 14s
created

Font::getSharedComponent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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