Completed
Pull Request — develop (#230)
by Franck
07:48
created

ColorMap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 72.72%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 77
ccs 8
cts 11
cp 0.7272
rs 10
c 3
b 1
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A changeColor() 0 4 1
A setMapping() 0 4 1
A getMapping() 0 4 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\Style;
19
20
/**
21
 * PhpOffice\PhpPresentation\Style\ColorMap
22
 */
23
class ColorMap
24
{
25
    const COLOR_BG1 = 'bg1';
26
    const COLOR_BG2 = 'bg2';
27
    const COLOR_TX1 = 'tx1';
28
    const COLOR_TX2 = 'tx2';
29
    const COLOR_ACCENT1 = 'accent1';
30
    const COLOR_ACCENT2 = 'accent2';
31
    const COLOR_ACCENT3 = 'accent3';
32
    const COLOR_ACCENT4 = 'accent4';
33
    const COLOR_ACCENT5 = 'accent5';
34
    const COLOR_ACCENT6 = 'accent6';
35
    const COLOR_HLINK = 'hlink';
36
    const COLOR_FOLHLINK = 'folHlink';
37
38
    /**
39
     * Mapping - Stores the mapping betweenSlide and theme
40
     *
41
     * @var array
42
     */
43
    protected $mapping = array();
44
45
    public static $mappingDefault = array(
46
        self::COLOR_BG1 => 'lt1',
47
        self::COLOR_TX1 => 'dk1',
48
        self::COLOR_BG2 => 'lt2',
49
        self::COLOR_TX2 => 'dk2',
50
        self::COLOR_ACCENT1 => 'accent1',
51
        self::COLOR_ACCENT2 => 'accent2',
52
        self::COLOR_ACCENT3 => 'accent3',
53
        self::COLOR_ACCENT4 => 'accent4',
54
        self::COLOR_ACCENT5 => 'accent5',
55
        self::COLOR_ACCENT6 => 'accent6',
56
        self::COLOR_HLINK => 'hlink',
57
        self::COLOR_FOLHLINK => 'folHlink'
58
    );
59
60
    /**
61
     * ColorMap constructor.
62
     * Create a new ColorMap with standard values
63
     */
64 198
    public function __construct()
65
    {
66 198
        $this->mapping = self::$mappingDefault;
67 198
    }
68
69
    /**
70
     * Change the color of one of the elements in the map
71
     *
72
     * @param string $item
73
     * @param string $newThemeColor
74
     */
75
    public function changeColor($item, $newThemeColor)
76
    {
77
        $this->mapping[$item] = $newThemeColor;
78
    }
79
80
    /**
81
     * Store a new map. For use with the reader
82
     *
83
     * @param array $arrayMapping
84
     */
85 4
    public function setMapping(array $arrayMapping = array())
86
    {
87 4
        $this->mapping = $arrayMapping;
88 4
    }
89
90
    /**
91
     * Get the whole mapping as an array
92
     *
93
     * @return array
94
     */
95 95
    public function getMapping()
96
    {
97 95
        return $this->mapping;
98
    }
99
}
100