Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
27 / 27 |
|
100.00% |
12 / 12 |
CRAP | |
100.00% |
1 / 1 |
Border | |
100.00% |
27 / 27 |
|
100.00% |
12 / 12 |
14 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getLineWidth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLineWidth | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getLineStyle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLineStyle | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
getDashStyle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDashStyle | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
getColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getHashCode | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
getHashIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setHashIndex | |
100.00% |
2 / 2 |
|
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 | use PhpOffice\PhpPresentation\ComparableInterface; |
23 | |
24 | class Border implements ComparableInterface |
25 | { |
26 | // Line style |
27 | public const LINE_NONE = 'none'; |
28 | public const LINE_SINGLE = 'sng'; |
29 | public const LINE_DOUBLE = 'dbl'; |
30 | public const LINE_THICKTHIN = 'thickThin'; |
31 | public const LINE_THINTHICK = 'thinThick'; |
32 | public const LINE_TRI = 'tri'; |
33 | |
34 | // Dash style |
35 | public const DASH_DASH = 'dash'; |
36 | public const DASH_DASHDOT = 'dashDot'; |
37 | public const DASH_DOT = 'dot'; |
38 | public const DASH_LARGEDASH = 'lgDash'; |
39 | public const DASH_LARGEDASHDOT = 'lgDashDot'; |
40 | public const DASH_LARGEDASHDOTDOT = 'lgDashDotDot'; |
41 | public const DASH_SOLID = 'solid'; |
42 | public const DASH_SYSDASH = 'sysDash'; |
43 | public const DASH_SYSDASHDOT = 'sysDashDot'; |
44 | public const DASH_SYSDASHDOTDOT = 'sysDashDotDot'; |
45 | public const DASH_SYSDOT = 'sysDot'; |
46 | |
47 | /** |
48 | * Line width. |
49 | * |
50 | * @var int |
51 | */ |
52 | private $lineWidth = 1; |
53 | |
54 | /** |
55 | * Line style. |
56 | * |
57 | * @var string |
58 | */ |
59 | private $lineStyle = self::LINE_SINGLE; |
60 | |
61 | /** |
62 | * Dash style. |
63 | * |
64 | * @var string |
65 | */ |
66 | private $dashStyle = self::DASH_SOLID; |
67 | |
68 | /** |
69 | * Border color. |
70 | * |
71 | * @var Color |
72 | */ |
73 | private $color; |
74 | |
75 | /** |
76 | * Hash index. |
77 | * |
78 | * @var int |
79 | */ |
80 | private $hashIndex; |
81 | |
82 | public function __construct() |
83 | { |
84 | $this->color = new Color(Color::COLOR_BLACK); |
85 | } |
86 | |
87 | /** |
88 | * Get line width (in points). |
89 | */ |
90 | public function getLineWidth(): int |
91 | { |
92 | return $this->lineWidth; |
93 | } |
94 | |
95 | /** |
96 | * Set line width (in points). |
97 | */ |
98 | public function setLineWidth(int $pValue = 1): self |
99 | { |
100 | $this->lineWidth = $pValue; |
101 | |
102 | return $this; |
103 | } |
104 | |
105 | /** |
106 | * Get line style. |
107 | */ |
108 | public function getLineStyle(): string |
109 | { |
110 | return $this->lineStyle; |
111 | } |
112 | |
113 | /** |
114 | * Set line style. |
115 | */ |
116 | public function setLineStyle(string $pValue = self::LINE_SINGLE): self |
117 | { |
118 | if ('' == $pValue) { |
119 | $pValue = self::LINE_SINGLE; |
120 | } |
121 | $this->lineStyle = $pValue; |
122 | |
123 | return $this; |
124 | } |
125 | |
126 | /** |
127 | * Get dash style. |
128 | */ |
129 | public function getDashStyle(): string |
130 | { |
131 | return $this->dashStyle; |
132 | } |
133 | |
134 | /** |
135 | * Set dash style. |
136 | */ |
137 | public function setDashStyle(string $pValue = self::DASH_SOLID): self |
138 | { |
139 | if ('' == $pValue) { |
140 | $pValue = self::DASH_SOLID; |
141 | } |
142 | $this->dashStyle = $pValue; |
143 | |
144 | return $this; |
145 | } |
146 | |
147 | /** |
148 | * Get Border Color. |
149 | */ |
150 | public function getColor(): ?Color |
151 | { |
152 | return $this->color; |
153 | } |
154 | |
155 | /** |
156 | * Set Border Color. |
157 | */ |
158 | public function setColor(?Color $color = null): self |
159 | { |
160 | $this->color = $color; |
161 | |
162 | return $this; |
163 | } |
164 | |
165 | /** |
166 | * Get hash code. |
167 | * |
168 | * @return string Hash code |
169 | */ |
170 | public function getHashCode(): string |
171 | { |
172 | return md5( |
173 | $this->lineStyle |
174 | . $this->lineWidth |
175 | . $this->dashStyle |
176 | . $this->color->getHashCode() |
177 | . __CLASS__ |
178 | ); |
179 | } |
180 | |
181 | /** |
182 | * Get hash index. |
183 | * |
184 | * Note that this index may vary during script execution! Only reliable moment is |
185 | * while doing a write of a workbook and when changes are not allowed. |
186 | * |
187 | * @return null|int Hash index |
188 | */ |
189 | public function getHashIndex(): ?int |
190 | { |
191 | return $this->hashIndex; |
192 | } |
193 | |
194 | /** |
195 | * Set hash index. |
196 | * |
197 | * Note that this index may vary during script execution! Only reliable moment is |
198 | * while doing a write of a workbook and when changes are not allowed. |
199 | * |
200 | * @param int $value Hash index |
201 | * |
202 | * @return $this |
203 | */ |
204 | public function setHashIndex(int $value) |
205 | { |
206 | $this->hashIndex = $value; |
207 | |
208 | return $this; |
209 | } |
210 | } |