Completed
Push — develop ( 2b41bd...39b55d )
by Adrien
22:48
created

Theme::getColourByIndex()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
4
5
/**
6
 * Copyright (c) 2006 - 2016 PhpSpreadsheet
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
 *
22
 * @category   PhpSpreadsheet
23
 * @copyright  Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
24
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
25
 * @version    ##VERSION##, ##DATE##
26
 */
27
class Theme
28
{
29
    /**
30
     * Theme Name
31
     *
32
     * @var string
33
     */
34
    private $themeName;
35
36
    /**
37
     * Colour Scheme Name
38
     *
39
     * @var string
40
     */
41
    private $colourSchemeName;
42
43
    /**
44
     * Colour Map indexed by position
45
     *
46
     * @var array of string
47
     */
48
    private $colourMapValues;
0 ignored issues
show
Unused Code introduced by
The property $colourMapValues is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
49
50
    /**
51
     * Colour Map
52
     *
53
     * @var array of string
54
     */
55
    private $colourMap;
56
57
    /**
58
     * Create a new Theme
59
     */
60 8
    public function __construct($themeName, $colourSchemeName, $colourMap)
61
    {
62
        // Initialise values
63 8
        $this->themeName = $themeName;
64 8
        $this->colourSchemeName = $colourSchemeName;
65 8
        $this->colourMap = $colourMap;
66 8
    }
67
68
    /**
69
     * Get Theme Name
70
     *
71
     * @return string
72
     */
73
    public function getThemeName()
74
    {
75
        return $this->themeName;
76
    }
77
78
    /**
79
     * Get colour Scheme Name
80
     *
81
     * @return string
82
     */
83
    public function getColourSchemeName()
84
    {
85
        return $this->colourSchemeName;
86
    }
87
88
    /**
89
     * Get colour Map Value by Position
90
     *
91
     * @return string
92
     */
93 3
    public function getColourByIndex($index = 0)
94
    {
95 3
        if (isset($this->colourMap[$index])) {
96 3
            return $this->colourMap[$index];
97
        }
98
99
        return null;
100
    }
101
102
    /**
103
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
104
     */
105
    public function __clone()
106
    {
107
        $vars = get_object_vars($this);
108
        foreach ($vars as $key => $value) {
109
            if ((is_object($value)) && ($key != '_parent')) {
110
                $this->$key = clone $value;
111
            } else {
112
                $this->$key = $value;
113
            }
114
        }
115
    }
116
}
117