Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
14 / 14 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
Shading | |
100.00% |
14 / 14 |
|
100.00% |
7 / 7 |
7 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getPattern | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setPattern | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
getColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getFill | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setFill | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * This file is part of PHPWord - A pure PHP library for reading and writing |
4 | * word processing documents. |
5 | * |
6 | * PHPWord 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/PHPWord/contributors. |
12 | * |
13 | * @see https://github.com/PHPOffice/PHPWord |
14 | * |
15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16 | */ |
17 | |
18 | namespace PhpOffice\PhpWord\Style; |
19 | |
20 | /** |
21 | * Shading style. |
22 | * |
23 | * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_Shd.html |
24 | * @since 0.10.0 |
25 | */ |
26 | class Shading extends AbstractStyle |
27 | { |
28 | /** |
29 | * Pattern constants (partly). |
30 | * |
31 | * @const string |
32 | * |
33 | * @see http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html |
34 | */ |
35 | const PATTERN_CLEAR = 'clear'; // No pattern |
36 | const PATTERN_SOLID = 'solid'; // 100% fill pattern |
37 | const PATTERN_HSTRIPE = 'horzStripe'; // Horizontal stripe pattern |
38 | const PATTERN_VSTRIPE = 'vertStripe'; // Vertical stripe pattern |
39 | const PATTERN_DSTRIPE = 'diagStripe'; // Diagonal stripe pattern |
40 | const PATTERN_HCROSS = 'horzCross'; // Horizontal cross pattern |
41 | const PATTERN_DCROSS = 'diagCross'; // Diagonal cross pattern |
42 | |
43 | /** |
44 | * Shading pattern. |
45 | * |
46 | * @var string |
47 | * |
48 | * @see http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html |
49 | */ |
50 | private $pattern = self::PATTERN_CLEAR; |
51 | |
52 | /** |
53 | * Shading pattern color. |
54 | * |
55 | * @var string |
56 | */ |
57 | private $color; |
58 | |
59 | /** |
60 | * Shading background color. |
61 | * |
62 | * @var string |
63 | */ |
64 | private $fill; |
65 | |
66 | /** |
67 | * Create a new instance. |
68 | * |
69 | * @param array $style |
70 | */ |
71 | public function __construct($style = []) |
72 | { |
73 | $this->setStyleByArray($style); |
74 | } |
75 | |
76 | /** |
77 | * Get pattern. |
78 | * |
79 | * @return string |
80 | */ |
81 | public function getPattern() |
82 | { |
83 | return $this->pattern; |
84 | } |
85 | |
86 | /** |
87 | * Set pattern. |
88 | * |
89 | * @param string $value |
90 | * |
91 | * @return self |
92 | */ |
93 | public function setPattern($value = null) |
94 | { |
95 | $enum = [ |
96 | self::PATTERN_CLEAR, self::PATTERN_SOLID, self::PATTERN_HSTRIPE, |
97 | self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS, |
98 | ]; |
99 | $this->pattern = $this->setEnumVal($value, $enum, $this->pattern); |
100 | |
101 | return $this; |
102 | } |
103 | |
104 | /** |
105 | * Get color. |
106 | * |
107 | * @return string |
108 | */ |
109 | public function getColor() |
110 | { |
111 | return $this->color; |
112 | } |
113 | |
114 | /** |
115 | * Set pattern. |
116 | * |
117 | * @param string $value |
118 | * |
119 | * @return self |
120 | */ |
121 | public function setColor($value = null) |
122 | { |
123 | $this->color = $value; |
124 | |
125 | return $this; |
126 | } |
127 | |
128 | /** |
129 | * Get fill. |
130 | * |
131 | * @return string |
132 | */ |
133 | public function getFill() |
134 | { |
135 | return $this->fill; |
136 | } |
137 | |
138 | /** |
139 | * Set fill. |
140 | * |
141 | * @param string $value |
142 | * |
143 | * @return self |
144 | */ |
145 | public function setFill($value = null) |
146 | { |
147 | $this->fill = $value; |
148 | |
149 | return $this; |
150 | } |
151 | } |