Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
32 / 32 |
|
100.00% |
20 / 20 |
CRAP | |
100.00% |
1 / 1 |
Title | |
100.00% |
32 / 32 |
|
100.00% |
20 / 20 |
21 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
isVisible | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setVisible | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setText | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getOffsetX | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setOffsetX | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getOffsetY | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setOffsetY | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getWidth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setWidth | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getHeight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setHeight | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getFont | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setFont | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getAlignment | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAlignment | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getHashCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
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\Shape\Chart; |
21 | |
22 | use PhpOffice\PhpPresentation\ComparableInterface; |
23 | use PhpOffice\PhpPresentation\Style\Alignment; |
24 | use PhpOffice\PhpPresentation\Style\Font; |
25 | |
26 | /** |
27 | * \PhpOffice\PhpPresentation\Shape\Chart\Title. |
28 | */ |
29 | class Title implements ComparableInterface |
30 | { |
31 | /** |
32 | * Visible. |
33 | * |
34 | * @var bool |
35 | */ |
36 | private $visible = true; |
37 | |
38 | /** |
39 | * Text. |
40 | * |
41 | * @var string |
42 | */ |
43 | private $text = 'Chart Title'; |
44 | |
45 | /** |
46 | * OffsetX (as a fraction of the chart). |
47 | * |
48 | * @var float |
49 | */ |
50 | private $offsetX = 0.01; |
51 | |
52 | /** |
53 | * OffsetY (as a fraction of the chart). |
54 | * |
55 | * @var float |
56 | */ |
57 | private $offsetY = 0.01; |
58 | |
59 | /** |
60 | * Width (as a fraction of the chart). |
61 | * |
62 | * @var float |
63 | */ |
64 | private $width = 0; |
65 | |
66 | /** |
67 | * Height (as a fraction of the chart). |
68 | * |
69 | * @var float |
70 | */ |
71 | private $height = 0; |
72 | |
73 | /** |
74 | * Alignment. |
75 | * |
76 | * @var Alignment |
77 | */ |
78 | private $alignment; |
79 | |
80 | /** |
81 | * Font. |
82 | * |
83 | * @var Font |
84 | */ |
85 | private $font; |
86 | |
87 | /** |
88 | * Hash index. |
89 | * |
90 | * @var int |
91 | */ |
92 | private $hashIndex; |
93 | |
94 | /** |
95 | * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Title instance. |
96 | */ |
97 | public function __construct() |
98 | { |
99 | $this->alignment = new Alignment(); |
100 | $this->font = new Font(); |
101 | $this->font->setName('Calibri'); |
102 | $this->font->setSize(18); |
103 | } |
104 | |
105 | /** |
106 | * Get Visible. |
107 | * |
108 | * @return bool |
109 | */ |
110 | public function isVisible() |
111 | { |
112 | return $this->visible; |
113 | } |
114 | |
115 | /** |
116 | * Set Visible. |
117 | * |
118 | * @param bool $value |
119 | * |
120 | * @return Title |
121 | */ |
122 | public function setVisible($value = true) |
123 | { |
124 | $this->visible = $value; |
125 | |
126 | return $this; |
127 | } |
128 | |
129 | /** |
130 | * Get Text. |
131 | * |
132 | * @return string |
133 | */ |
134 | public function getText() |
135 | { |
136 | return $this->text; |
137 | } |
138 | |
139 | /** |
140 | * Set Text. |
141 | * |
142 | * @param string $value |
143 | * |
144 | * @return Title |
145 | */ |
146 | public function setText($value = null) |
147 | { |
148 | $this->text = $value; |
149 | |
150 | return $this; |
151 | } |
152 | |
153 | /** |
154 | * Get OffsetX (as a fraction of the chart). |
155 | */ |
156 | public function getOffsetX(): float |
157 | { |
158 | return $this->offsetX; |
159 | } |
160 | |
161 | /** |
162 | * Set OffsetX (as a fraction of the chart). |
163 | */ |
164 | public function setOffsetX(float $value = 0.01): self |
165 | { |
166 | $this->offsetX = $value; |
167 | |
168 | return $this; |
169 | } |
170 | |
171 | /** |
172 | * Get OffsetY (as a fraction of the chart). |
173 | */ |
174 | public function getOffsetY(): float |
175 | { |
176 | return $this->offsetY; |
177 | } |
178 | |
179 | /** |
180 | * Set OffsetY (as a fraction of the chart). |
181 | */ |
182 | public function setOffsetY(float $pValue = 0.01): self |
183 | { |
184 | $this->offsetY = $pValue; |
185 | |
186 | return $this; |
187 | } |
188 | |
189 | /** |
190 | * Get Width (as a fraction of the chart). |
191 | */ |
192 | public function getWidth(): float |
193 | { |
194 | return $this->width; |
195 | } |
196 | |
197 | /** |
198 | * Set Width (as a fraction of the chart). |
199 | */ |
200 | public function setWidth(float $pValue = 0): self |
201 | { |
202 | $this->width = $pValue; |
203 | |
204 | return $this; |
205 | } |
206 | |
207 | /** |
208 | * Get Height (as a fraction of the chart). |
209 | */ |
210 | public function getHeight(): float |
211 | { |
212 | return $this->height; |
213 | } |
214 | |
215 | /** |
216 | * Set Height (as a fraction of the chart). |
217 | */ |
218 | public function setHeight(float $value = 0): self |
219 | { |
220 | $this->height = $value; |
221 | |
222 | return $this; |
223 | } |
224 | |
225 | /** |
226 | * Get font. |
227 | */ |
228 | public function getFont(): ?Font |
229 | { |
230 | return $this->font; |
231 | } |
232 | |
233 | /** |
234 | * Set font. |
235 | * |
236 | * @param null|Font $pFont Font |
237 | */ |
238 | public function setFont(?Font $pFont = null): self |
239 | { |
240 | $this->font = $pFont; |
241 | |
242 | return $this; |
243 | } |
244 | |
245 | /** |
246 | * Get alignment. |
247 | * |
248 | * @return Alignment |
249 | */ |
250 | public function getAlignment() |
251 | { |
252 | return $this->alignment; |
253 | } |
254 | |
255 | /** |
256 | * Set alignment. |
257 | * |
258 | * @return Title |
259 | */ |
260 | public function setAlignment(Alignment $alignment) |
261 | { |
262 | $this->alignment = $alignment; |
263 | |
264 | return $this; |
265 | } |
266 | |
267 | /** |
268 | * Get hash code. |
269 | * |
270 | * @return string Hash code |
271 | */ |
272 | public function getHashCode(): string |
273 | { |
274 | return md5($this->text . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__); |
275 | } |
276 | |
277 | /** |
278 | * Get hash index. |
279 | * |
280 | * Note that this index may vary during script execution! Only reliable moment is |
281 | * while doing a write of a workbook and when changes are not allowed. |
282 | * |
283 | * @return null|int Hash index |
284 | */ |
285 | public function getHashIndex(): ?int |
286 | { |
287 | return $this->hashIndex; |
288 | } |
289 | |
290 | /** |
291 | * Set hash index. |
292 | * |
293 | * Note that this index may vary during script execution! Only reliable moment is |
294 | * while doing a write of a workbook and when changes are not allowed. |
295 | * |
296 | * @param int $value Hash index |
297 | * |
298 | * @return Title |
299 | */ |
300 | public function setHashIndex(int $value) |
301 | { |
302 | $this->hashIndex = $value; |
303 | |
304 | return $this; |
305 | } |
306 | } |