Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
ColorMap | |
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
changeColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
setMapping | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getMapping | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
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 | * @see https://github.com/PHPOffice/PHPPresentation |
14 | * |
15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16 | */ |
17 | |
18 | declare(strict_types=1); |
19 | |
20 | namespace PhpOffice\PhpPresentation\Style; |
21 | |
22 | /** |
23 | * PhpOffice\PhpPresentation\Style\ColorMap. |
24 | */ |
25 | class ColorMap |
26 | { |
27 | public const COLOR_BG1 = 'bg1'; |
28 | public const COLOR_BG2 = 'bg2'; |
29 | public const COLOR_TX1 = 'tx1'; |
30 | public const COLOR_TX2 = 'tx2'; |
31 | public const COLOR_ACCENT1 = 'accent1'; |
32 | public const COLOR_ACCENT2 = 'accent2'; |
33 | public const COLOR_ACCENT3 = 'accent3'; |
34 | public const COLOR_ACCENT4 = 'accent4'; |
35 | public const COLOR_ACCENT5 = 'accent5'; |
36 | public const COLOR_ACCENT6 = 'accent6'; |
37 | public const COLOR_HLINK = 'hlink'; |
38 | public const COLOR_FOLHLINK = 'folHlink'; |
39 | |
40 | /** |
41 | * Mapping - Stores the mapping betweenSlide and theme. |
42 | * |
43 | * @var array<string, string> |
44 | */ |
45 | protected $mapping = []; |
46 | |
47 | /** |
48 | * @var array<string, string> |
49 | */ |
50 | public static $mappingDefault = [ |
51 | self::COLOR_BG1 => 'lt1', |
52 | self::COLOR_TX1 => 'dk1', |
53 | self::COLOR_BG2 => 'lt2', |
54 | self::COLOR_TX2 => 'dk2', |
55 | self::COLOR_ACCENT1 => 'accent1', |
56 | self::COLOR_ACCENT2 => 'accent2', |
57 | self::COLOR_ACCENT3 => 'accent3', |
58 | self::COLOR_ACCENT4 => 'accent4', |
59 | self::COLOR_ACCENT5 => 'accent5', |
60 | self::COLOR_ACCENT6 => 'accent6', |
61 | self::COLOR_HLINK => 'hlink', |
62 | self::COLOR_FOLHLINK => 'folHlink', |
63 | ]; |
64 | |
65 | /** |
66 | * ColorMap constructor. |
67 | * Create a new ColorMap with standard values. |
68 | */ |
69 | public function __construct() |
70 | { |
71 | $this->mapping = self::$mappingDefault; |
72 | } |
73 | |
74 | /** |
75 | * Change the color of one of the elements in the map. |
76 | */ |
77 | public function changeColor(string $item, string $newThemeColor): self |
78 | { |
79 | $this->mapping[$item] = $newThemeColor; |
80 | |
81 | return $this; |
82 | } |
83 | |
84 | /** |
85 | * Store a new map. For use with the reader. |
86 | * |
87 | * @param array<string, string> $arrayMapping |
88 | */ |
89 | public function setMapping(array $arrayMapping = []): self |
90 | { |
91 | $this->mapping = $arrayMapping; |
92 | |
93 | return $this; |
94 | } |
95 | |
96 | /** |
97 | * Get the whole mapping as an array. |
98 | * |
99 | * @return array<string, string> |
100 | */ |
101 | public function getMapping(): array |
102 | { |
103 | return $this->mapping; |
104 | } |
105 | } |